put in an '&' and now it provides no intializer

if i add a & it provides no intialzer


1
2
3
4
5
6
7
8
9
10
class rateChange{
public:
	rateChange();
	int& monthChange;
	int& weekChange;
	int& dayChange;
};

rateChange::rateChange(){
};


but when i do


1
2
3
4
5
6
7
8
9
10
class rateChange{
public:
	rateChange();
	int monthChange;
	int weekChange;
	int dayChange;
};

rateChange::rateChange(){
};


it works fine.

help?
Why do you want to store references?
to have them appear later in the program. i want to have the user write them, then later read them.
I don't understand what you say but you can use references if you initialize them in the constructor initializer list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class rateChange{
public:
	rateChange(int&, int&, int&);
	int& monthChange;
	int& weekChange;
	int& dayChange;
};

rateChange::rateChange(int& mc, int& wc, int& dc)
:	monthChange(mc),
	weekChange(wc),
	dayChange(dc)
{
};
Last edited on
thank you.
Topic archived. No new replies allowed.