I am having trouble using static function. I am initialising two static variables in GetResult() Function and then trying to get result using get_ans1() and get_ans2(). All the functions and variables are static. Have a look.
Static variables are class variables, why should they be defined outside the class?
Also see the msdn article :http://msdn.microsoft.com/en-us/library/s1sb61xd.aspx.
I think there might be problem in the Main function..
When you declare a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. A static data member must be defined at file scope. An integral data member that you declare as conststatic can have an initializer
In fact, static members have the same properties as global variables but they enjoy class scope. For that reason, and to avoid them to be declared several times, we can only include the prototype (its declaration) in the class declaration but not its definition (its initialization). In order to initialize a static data-member we must include a formal definition outside the class, in the global scope