Error: A nonstatic member reference must be relative to a specific object

Oct 23, 2011 at 2:06am
That is what I get whenever I call any function within the SI class. what am I doing wrong? Here is the code(I am only showing the part that currently matters in this discussion):

1
2
3
4
5
6
7
8
9
10
11
12
13
int _tmain(int argc, _TCHAR* argv[]){ 
	SI.SI();
	bool cote = true;
	while (cote == true) {
     double Ret = ComputeAnswer(GetOperand(1), GetOperator(), GetOperand(2));
     SI.Display("Result is: ", 3)
     SI.Display(Ret);
	 if (SI.SendaReceiveYesorNoAnswer("\nContinue?\n") == true) {
		 SI.ClearOutput();
	 }
	}
	return 0;
}
Oct 23, 2011 at 2:20am
Sounds like it's complaining that you're asking for a variable from an object, but you're using the class name to get it instead of the object variable.
Oct 23, 2011 at 6:16pm
Then how do I define an object variable?
Oct 23, 2011 at 6:24pm
The same way you declare a regular variable:

1
2
3
4
5
6
type variablename;

// example:
int myint;  // creates a variable that's an int

SI mysi;  // creates an object that's a SI 
Oct 24, 2011 at 2:10pm
Thanks! It worked!
Topic archived. No new replies allowed.