"IntelliSense: a nonstatic member reference must be relative to a specific object"
That error seems to imply you did this:
//INVALID CODE:
class MyClass
{
public:
int myVariable;
static void MyFunction()
{
//... code that uses 'myVariable'...
}
};
In this example, 'myVariable' isn't a global. It is a member-variable that belongs to one specific "instance" of that class.
The function 'MyFunction()' on the other hand, is 'static' which means it doesn't belong to any specific "instance".
Functions that are static can't use member-variables that aren't static.
This is a little confusing, but as you keep learning about classes and also keep testing code yourself, you'll come to understand it.
There's a difference between a type of class (like "class Dog" is a new 'Dog' type of class) and an instance of a class ("Dog fluffy;" is an instance of the Dog class, named fluffy). The difference between a type and an instance is an important difference, but it took me awhile to learn it when I first started programming.
Dog fluffy = ...
int currentYear = 2014;
'int' is a type of variable. 'Dog' is a type of variable.
'currentYear' is a specific instance of an 'int'. 'fluffy' is a specific instance of a 'Dog'.