The C++ book I'm following is just getting to classes. I'm completing an exercise where I have to make a class with a single member variable, an int. The constructor sets the member int to the value given and outputs a string and the member int. The destructor does the same. Here's my program:
Ohhhh, I kinda thought that the constructor would automatically associate it with the member variable num. I added the line this->num = num; to the constructor and it works as it should now, thanks!
EDIT: Occurred to me after I typed this that it would probably just be easier to change the argument's name.
@PJYang2010
'this' is a pointer to the object being manipulated, so you can't acces member functions or variables via dot operator unless you do (*this).num though this->num looks way better.
I really like the way the '->' operator looks :D