#include <iostream> #include <fstream> using namespace std; int main() { TestClass obj; // TestClass 클래스 객체 생성 obj.init("delay_time", "ms", "UINT32", 4); // TestClass에는 init() 맴버 함수가 있다고 가정함. obj.set("012345"); // TestClass에는 set() 맴버 함수가 있다고 가정함. cout << "obj => " << obj << endl; // TestClass는 연산자 << 를 오버로딩함. fstream fs("mibentry.bin", ios::binary); // 객체 직렬화 - 쓰기 fs.write((char*)&obj, sizeof(obj)); MibEntry copied_obj; fs.seekg(0); // 객체 직렬화 - 읽기 fs.read((char*)&copied_obj, sizeof(copied_obj)); cout << "copied_obj => " << copied_obj << endl; return 0; }
Cpp
2010.07.15 11:14
Object Serialization Example
조회 수 36944 추천 수 0 댓글 0
TAG •