The const key word
what are the differences between both following prototypes (const key word) :
void FillDeck(Card* const wDeck);
void deal(const Card* const wDeck);
Cheers !!
In the deal function you can't modify the actual pointer (not the data pointed to), passing value-types by const is rarely done in practice and is not needed for const-correctnes.
The following will be legal.
But in deal you would get an error because wDeck is constant and can only be passed by value or const reference.
The following will be legal.
void FillDeck(Card* const wDeck){ // ShuffleDeck takes a non-const reference ShuffleDeck(wDeck); // Do something}
But in deal you would get an error because wDeck is constant and can only be passed by value or const reference.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement