I made a simple class to introduce the door. To return variables, I refer to them with a pointer this. Regarding easy access to variables, what is the difference between accessing them with thisand without a pointer ?
class Door
{
protected:
bool shut;
public:
Door();
bool isOpen();
void Open();
void Close();
};
Door::Door()
{}
bool Door::isOpen()
{
return this->shut;
}
void Door::Open()
{
this->shut = false;
}
void Door::Close()
{
if(this->isOpen()) this->shut = true;
}
It may not be here, but what about more complex classes?
source
share