Hello, I am new to using classes and I'm not 100% sure if I'm doing this right, and I don't understand why I'm getting the error:
37:24: error: cannot call member function 'void stats::push(int)' without object
39:20: error: cannot call member function 'void stats::print()' without object
(compiling on g++)
Can anybody please explain what this means in relevance to my code? (I tried google to no avail :\)
The error is because you cannot call member functions that are not part of an instantiated object.
1 2 3 4 5 6 7 8 9 10
int main()
{
stats stat; //Instantiate a stats object.
int numin = 0;
while(std::cin >> numin)
stat.push(numin); //Push numin into stat
stat.print(); //stat.print(); not stats::print()
return 0;
}