Hi, I just started learning more about class/objects. What is the purpose of using 'this' pointers and static members? How exactly do you use them?
These are some small examples:
class SomeClass
{
private:
int num;
public:
void setNum(int num)
{ this->num = num; }
};
What is 'this->' doing to num?
class IntVal
{
public:
intVal(int val = 0)
{ value = val; valCount++ }
int getVal();
void setVal(int);
private:
int value;
static int valCount;
};
//In-class declaration
static int valCount;
//Other members not shown
};
//Definition outside of class
int IntVal::valCount = 0;
What is the purpose of making it static and setting it to 0?