Help with pointer types.

I was working through the introduction section in Visual C++ Express edition help, when I came across the following:

1
2
3
4
5
    Cardgame *bridge = 0;
    Cardgame *blackjack = 0;
    Cardgame *solitaire = 0;
    Cardgame *poker = 0;


Can anyone explain why those pointer declarations would be valid? I thought that pointers had to declare the type they pointed to. I know that they can be used to point to functions but I thought that in order to do that they had to be declared like the prototype of the function. In this case wouldn't

int (*bridge)(int)=Cardgame

be more appropriate?

Thanks in advance for your thoughts.
Last edited on
Pointers can point to classes and structs. Making them equal to 0 is the same as setting them to null.

//define Cardgame struct
struct Cardgame
{
string name;
int player1score;
int player2score;
int player3score;
int player4score;
};

//Initiate null cardgame
Cardgame * blackjack = 0;
Topic archived. No new replies allowed.