E
Erik2000
I would really like to use a vector that can store any type: a float,
double, int, or object. Is there a way to do this?
double, int, or object. Is there a way to do this?
Erik2000 said:I would really like to use a vector that can store any type: a float,
double, int, or object. Is there a way to do this?
I tried something using list this week. I hope same thing can be done
with vector too.
class myBaseData
{
virtual void myMethod1() = 0;
};
class myIntData : public myBaseData
{
public: myMethod1() { }
};
class myFloatData: public myBaseData
{
public: myMethod1() { }
};
typedef list<myBaseData *> myBaseDataList;
main()
{
myBaseDataList myDataTypeList;
for(myBaseDataList::iterator ii = myDataTypeList.begin();
ii!=myDataTypeList.end();ii++)
{
myBaseData *tmp = *ii;
tmp->myMethod1();
}
}
Its ++C, not C++ damn it.
Greg said:No, Bjarne was shooting for maximum backwards compatibility with C, so
he felt that since C++ returns the same value as C that would be a
better choice of name. And, judging from C99, one of the results of C++
was that C was modified, so the decision was, in retrospect, truly
inspired!
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.