Mindtraveller wrote on Mon, 08 September 2008 05:25
Simplified code as a description of problem:
class Project
{
Project(TabCtrl &tabs) {/*add new tab with Project controls*/}
};
class App
{
void Serialize (Stream &stream) {stream % projects;} //ERROR: no default constructor available
Array<Project> projects;
TabCtrl mainTabs;
};
Is there a way I can fetch my Project objects with auto-adding to the tabs?
Yes, but not really recomended
The trick would be to implement your own Array serialization, using "new" variant of Add.
Something like:
if(s.IsLoading())
projects.Clear();
int count = projects.GetCount();
s % count;
for(int i = 0; i < count; i++)
if(s.IsStoring())
s % projects[i];
else
s % projects.Add(new Project(tabs));
(I would rather find some other solution. IMO, except special cases, classes should have default constructors).