I'm trying to create a vector of objects, i don't know what is going wrong.
here the code
class nave {
public:
void sx(int i); int x();
void sy(int i); int y();
};
vector<nave> naves();
naves.push_back(nave);
cout << naves.size();
Change -
vector<nave> naves(); // naves() is a function declaration whose return type
// is vector<nave>
to
vector<nave> naves;
A vector is just like any other class. Declare it thus:
vector<nave> naves;
naves.push_back(nave());
. Notice the ()
Mahesh 2012-04-04 20:01
vector<nave*> naves;
MPelletier 2012-04-04 20:05
Do this:
vector<nave> naves;
naves.push_back(nave());
vector<nave> naves();
was interpreted as a function declaration.naves.push_back(nave);
did not actually instantiate nave
.