I'm getting these errors with the code blocks IDE(with g++ compiler) "is private" for every member variable. As far as I know it is only legal to use the private variables within the other members, which is what i'm doing. This is the code of my cpp
/*
bullsAndCows.cpp
*/
using namespace std;
//enum class state {_bull, _cow, _none};
class bullsAndCows {
private:
const int m_size{4};
bool m_guessed{false};
std::vector<char> m_digit;
std::vector<state> m_digitState;
public:
bullsAndCows() {
m_guessed = false;
for(int i = 0; i < m_size; i++)
m_digitState[i] = state._none;
}
void bullsAndCows::setGuessed(bool value) { _guessed = value; }
bool bullsAndCows::getGuessed() { return _guessed; }
void bullsAndCows::setDigit(char value, int i) { m_digit[i] = value; }
char bullsAndCows::getDigit(int i) { return m_digit[i]; }
void bullsAndCows::setDigitState(state value, int i) { m_digitState[i] = value; }
state bullsAndCows::getDigitState(int i) { return m_digitState[i]; }
};
this the code of my main, where i'm testing. #include "bullsAndCows.h"
using namespace std;
int main()
{
bullsAndCows game;
for(int i = 0; i < game.m_size; i++) {
cin >> game.m_digit[i];
cout << game.m_digit[i];
}
return 0;
}
The c++11 flag is activated on the compiler
Aucun commentaire:
Enregistrer un commentaire