Question

Here is my default constructor for a class called Blackjack:

Blackjack::Blackjack(char *names[], int numPlayers)
:m_names('jane'),m_numPlayers(numPlayers)

in the "Private:" I have "char m_names;" to give it a default value, what would i name it under the constructor?

Was it helpful?

Solution

You cannot actually use a default parameter for names before you use one for numPlayers, which is all to the good.

Define an external char const * const* in the same header before the constructor, and use that name as default. Take a corresponding int constant for numPlayers...

Don't forget to define your constant in your cpp file.

Aside: I'm counting on you to add the needed const qualifiers to names

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top