Hello guys i got a error when im doing this in c++.
class Position {
private:
int posX;
int posY;
public:
Position(int posX, int posY) {
this->posX = posX;
this->posY = posY;
}
int getPosX() {
return posX;
}
int getPosY() {
return posY;
}
};
class SpaceShip {
private:
Position position;
public:
SpaceShip(Position position) {
this->position = position;
}
};
int main() {
Position position(10, 10);
SpaceShip spaceShip(position);
return 0;
}
and the error i got is this.
Doesn't exist any default constructor for the clase "Position"
What i could do to solve the problem?
And also, What is the correct form to create a object attribute for a class?