I’m having problem with using vectors of my own class. My intension is to create a new object on every spacebar click. I’ve already written some code:
classes.h
class someClass
{
public:
short x;
short y;
someClass::someClass();
};
classes.cpp
someClass::someClass()
{
x = 0;
y = 0;
}
main.cpp
using namepsace std;
vector<someClass> vMyVector;
(...)
case SDLK_SPACE:
vMyVector.push_back();
break;
I also tried put that extra line in case SDLK_SPACE:
someClass *temp = new someClass();
vMyVector.push_back(temp);
But in both situations compiler return errors like
error C3867: ‘std::vector<_Ty>::push_back’: function call missing
argument list; use ‘&std::vector<_Ty>::push_back’ to create a pointer
to member with [_Ty=someClass]
I’ve already spend about an hour on searching some books and reading various topics on the Internet, but none of them were useful. I put my hope in you guys!
You declared the vector containing objects of someClass but tried to add a pointer.
Write instead
or