Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Problem using more classes...
Re: Problem using more classes... [message #35654 is a reply to message #35645] Sat, 10 March 2012 13:49 Go to previous messageGo to previous message
Sender Ghost is currently offline  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:
prova4 p;
int result = p.sum(1, 2);
 
Read Message
Read Message
Read Message
Previous Topic: array : minimum value
Next Topic: Sizeable().Zoomable()
Goto Forum:
  


Current Time: Tue May 07 23:59:09 CEST 2024

Total time taken to generate the page: 0.01382 seconds