I have a class, Game
, which has in argument a std::vector
of another class, Case
. In this class Case
, I have a function which tells me when we click on it. And I want to send a signal to my object Game
, which owns the Cases
, when a Case
is pressed.
In game.h :
class Game
{
public:
Game();
void doSomething();
private:
std::vector<Case> board;
};
And in case.h :
class Case
{
public:
Case(Game &g);
void functionWhichIsCalledWhenCaseIsPressed();
private:
Game game;
};
So, when the functionWhichIsCalledWhenCaseIsPressed()
is called, I want to call the function doSomething()
.
EDIT :
I tried, but I also need to create a case out of the vector... Actually, I have a Case c;
in my Game.h... And I cannot initialize it... I tried c = Game(*this);
But I have an error :
error: object of type 'Case' cannot be assigned because its copy assignment operator is implicitly delete
EDIT : Thank you, it's done !