I am trying to push a pointer into a vector, but my compiler gives me the error:
request for member 'Add_Object' in theContainer, which is of non-agregate type 'Container(X)'
Please tell me what I am doing wrong. Here is my code:
#include <vector.h>
#include <iostream>
class Object
{
private:
short data;
public:
Object(){data = 1;};
};
typedef Object::Object* pObject;
class Container
{
private:
vector<pObject> v;
public:
Container(){v.reserve(1);};
void Add_Object(pObject o){v.push_back(o);}; // What am I doing wrong?
};
int main()
{
Container theContainer();
theContainer.Add_Object( new Object() ); // Compiler gives Error message Here
return(0);
}
thanks for any advice you might offer.
wj