Ah, so that's a run-time error at least (as opposed to compiler error).
In line 10 of maexle.h, you define a member variable, mPlayers.
In line 11 of maexle.cpp, you declare a local variable, mPlayers.
This local variable
shadows the member variable, hiding the member variable.
To make things more complicated, you have a class inheritance hierarchy, albeit a simple one.
Do something similar to what I showed in my previous post,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
class CVector
{
public:
CVector(int pSpieler); // define this!
vector <string> mPlayers;
vector <int> penalties;
};
// ...
CVector::CVector(int pPlayer)
: mPlayers(pPlayers),
penalties(0) // assume we start with 0 penalties, change if necessary
{
}
// ...
CStart::CStart(int pPlayer)
: CVector(pPlayer) // calls the base-class constructor
{
for (int i = 0; i < pPlayer; i++) {
cout << "Player " << i+1 << ": ";
cin >> mPlayers.at(i);
}
}
| |
PS: In English, past tense usually follows the pattern of becoming "-ed", never "-et", e.g. "delete" --> "deleted".
I just say this because I know it's a common mistake German-speakers make.