Original Post
I am trying to use the STL vector in combination with multiple-inhearence:
I must have a vector based on the class cObj, and i want to add a cBall obj that is derived from cObj. I thought of using pure virtual functions, but dunno how since i get compilation an error: "Can allocate an Object type 'cObj' since the function Draw() is abstract".
#include <iostream>
#include <vector>
class cObj
{
public:
virtual void Draw()=0;
};
class cBall : public cObj
{
public:
virtual void Draw() {cout << "o";}
};
int main()
{
vector v;
cBall *b = new cBall;
v.push_back(*b);
cObj *o = new cBall;
v.push_back(*o);
return 0;
}
Are stuff like dynamic/static casting the right sollution? (i dont know what casting are and why to use it anyway...)
[edited by - PopJimmy on June 1, 2003 1:15:38 AM]