나는 Shapes 클래스와 gShapes 벡터를 가지고있다. 오브젝트를 벡터 파일로 작성하고 있습니다.벡터에서 파일로 데이터를 씁니다. C++
char* str;
vector<Shape*>::iterator it;
for(it = gShapes.begin(); it != gShapes.end(); it++)
{
str = reinterpret_cast<char*>(reinterpret_cast<void*>(*it));
saveFile.write(str, sz);
}
내 클래스에 동적 메모리를 추가하기 전까지는 완벽하게 작동 했으므로 이제이 코드는 데이터가 아닌 파일에 포인터를 씁니다.
개체를 완전히 serialize해야합니다. 예를 들면 다음과 같습니다. http://www.boost.org/doc/libs/1_53_0/libs/serialization/doc/index.html – Chad