argument of type `int (CaloCell::)()' does not match `int'

Hey guys,

Pls help, I'm trying to compile the following program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CALOCELL_HH
#define CALOCELL_HH



class CaloCell
{
	private:
		double e;
		int i;
		//CaloCell calocell;
	public:

		CaloCell(double energy, int ID) : e(getValenergy), i(getValid) {};
		
		
		double getValenergy() const { return e;}
		
		
		void setValenergy(double newenergy) { e = newenergy;}
		
		int getValid() const { return i;}
		
		
		void setValid(int newid) { i = newid;}


};

#endif 



and the main program is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include "calocell.hh"

using std::cout;
using std::endl;

int main()
{
CaloCell c(2.2,2);
//c.CaloCell (2.2,2);
cout << "energy:" ;
c.getValenergy(); 
cout << endl << endl ;
return 0;
}


I'm getting the following as error message:



In file included from main.cc:2:
calocell.hh: In constructor `CaloCell::CaloCell(double, int)':
calocell.hh:7: error: argument of type `int (CaloCell::)()' does not match `int'


Could anyone pls tell me what is going wrong here?
Thanks
What the hell is going on in that constructor?
You're using your class's get functions to initialize variables that have not yet been initialized so you are doomed to get some kind of undefined behavior. Not to mention that those are functions and not objects/variables so you are missing the call operator.
Your constructor should look like this
CaloCell(double energy, int ID) : e(energy), i(ID) {};
hey thanks a ton...
kinda new to this thing, so got a little confused with all the initializing!
the program works fine now ! :)
...and the semicolon should not follow the body of the constructor.
Topic archived. No new replies allowed.