The const key word

Started by
2 comments, last by jolyqr 17 years, 8 months ago
what are the differences between both following prototypes (const key word) : void FillDeck(Card* const wDeck); void deal(const Card* const wDeck); Cheers !!
Advertisement
Check this out
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
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.
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.
cheers guys !!

This topic is closed to new replies.

Advertisement