#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 •
번호 | 카테고리 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
147 | Network | IEEE 802.15.4 | 비트겐스 | 2010.08.18 | 20391 |
» | Cpp | Object Serialization Example | 비트겐스 | 2010.07.15 | 36944 |
145 | Diary | 이제 민방위~ㅋㅋ 1 | 비트겐스 | 2010.04.12 | 12237 |
144 | Diary |
사진뒤져보니~
![]() |
비트겐스 | 2010.04.10 | 24647 |
143 | CSharp | EUC-KR로 인코딩된 URL 디코딩하기 | 비트겐스 | 2010.04.07 | 28375 |