In C++, how can I achieve the following:
// player.h
#ifndef PLAYER_H
#define PLAYER_H
class Player {
    public:
        Player(Cake* cake);
}
#endif
// player.cpp
#include "cake.h"
#include "player.h"
Player::Player(Cake* cake) { }
// cake.h
#ifndef CAKE_H
#define CAKE_H
class Cake {
    public:
        Cake( );
}
#endif
// cake.cpp
#include "cake.h"
Cake::Cake() { }
// main.cpp
#include "player.h"
#include "cake.h"
int main() {
    Cake* cake();
    Player* player(cake); // This does not work
    return 0;
}
In other words, Have a Player pointer that takes a Cake pointer in it's constructor.
However, when I try compiling the application with g++ i get the following error:
error: cannot convert ‘Cake* (*)()’ to ‘Player*’ in initialization.
It probably makes sense, but I'd like to know why I can't have a pointer that takes a pointer (in the constructor).
 
     
     
     
    