1

I want to serialize my data and i have polymorphic classes .

Initially when i was learning the process of the Serialization i declared the Inherited class in their header files.

  Header file for Sphere which is sub class of geometry
  BOOST_CLASS_EXPORT(Sphere)

but when i tried doing in my project i got the linker error2005 stating that the object is already defined in the object.

So i tried declaring the BOOST_CLASS_EXPORT(Sphere) in the cpp file but than i got error message derived class not registered or exported.

Eventually i got it working by declaring the derived class in the Main file.

  BOOST_CLASS_EXPORT_GUID(Sphere, "Sphere"); 

But the problem here is that if i have 30 objects i will need to declare them in the main file and if i add any new classes than again i need to declare them in main file.

Can i define the export in their header or cpp files of the class.

1 Answers1

1

You want to separate the export KEY and IMPLEMENTATION.

I have some very complete answers up, some of which also touch on polymorphism and abstract bases. See there for good suggestions:

sehe
  • 374,641
  • 47
  • 450
  • 633