C++ question about public data member?

Lets say that I have the following class:

class Car:
{
private:
bool RaceCarStatus;
public:
Car()
{
RaceCarStatus = false;
}
~Car()
{
RaceCarStatus = false;
}
void setRaceCarStatus(bool y)
{
RaceCarStatus=y;
}
bool getRaceCarStatus()
{
return RaceCarStatus;
}
};

// the main looks like this:
int main()
{
Car y;
cout << "Initial value for y: " << endl;
cout<< " Race Car Status= "<< y.getRaceCarStatus()<< endl;
y.setRaceCarStatus(true);
cout << "Modified value for y: " << endl;
cout<<" Race Car Status= "<< y.getRaceCarStatus() <<endl;
return 0;
}

In class Car, we define data member RaceCarStatus as public. Under this circumstance, are setRaceCarStatus() and getRaceCarStatus() necessary ? Why ?
If it was public there would be no need for the get/set functions.
Topic archived. No new replies allowed.