Original Post
🔒 Locked
Dynamic variable creating
Advertisement
No. You need to make an (abstract) base class that provides the operations you need from the type.
[edited by - civguy on December 29, 2002 6:28:55 AM]
class SomeType {
virtual void hitMe() = 0;
virtual ~SomeType() {}
};
class Type1 : public SomeType {
virtual void hitMe() {...}
};
class Type2 : public SomeType {
virtual void hitMe() {...}
};
...
SomeType *TempVar;
if (...)
{
TempVar = new Type1;
}
else if (...)
{
TempVar = new Type2;
}
[edited by - civguy on December 29, 2002 6:28:55 AM]
Or maybe boost::any. Depends on what you''re trying to do.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
