문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top