Sender Ghost Messages: 301 Registered: November 2008
Senior Member
Hello, Matteo.
idkfa46 wrote on Fri, 09 March 2012 17:18
calling function prod() from the same class (prova3) there are no problems but if I try to call back sum(x, y) from a different class (prova4) I receive the following error:
'prova4::sum' : illegal call of non-static member function
c:\myapps\prova3\prova3.h(28) : see declaration of 'prova4::sum'
Where I'm wrong today ?!
As compiler message said, you need static prova4::sum function to use it this way:
class prova4 {
public:
static int sum (int x, int y) { return x + y; }
};
Else you need to create object instance of prova4 class for using it: