
Originally Posted by
kempofighter
I'm not sure how you could do it without making it a singleton. The index attribute is non-static as is the serialize function. Therefore each object has its own copies of the class attributes. I'm not sure why you expected the serialize function to do anything special for you.
OK! Let me rethink this.
Here's another question: Assume the messages were singleton.
Given:
Code:
D1* ptr2 = static_cast< D1* > ( simple.GetInstance ( 1 ) );
This results in a call to:
Code:
template <class Base, class Derived>
static Base* create()
{
std::cout << "." << std::endl;
return new Derived;
}
Since the Derived type was is wrapped in a Singleton, I'm assuming there's nothing inherently wrong calls to "Create" - after initial call (ptr). True?