Function as left operand

I am working on an assignment from class and I am getting the following error in my code.

grtax.cpp(30): error C2659: '=' : function as left operand

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  
My class header file looks like this:

#pragma once
// Define RateType Variable
enum RateType {LiveInWorkIn, LiveOutWorkOut, LiveOutWorkIn, LiveInWorkOut};

class GRTax
{
public:
	float CGRTax(RateType, float);
	float CGRTax();
	float SetRate(RateType);
	float mTaxableIncome(void);
	float mTaxRate(void);
	RateType mRate(void);
	GRTax(void);
	~GRTax(void);
};

and the code from my .cpp file that has the error.

float GRTax::SetRate(RateType)
{
	int Selection;
	
	cout << "Please choose:\n";
	cout << "1 for LiveInWorkIn\n";
	cout << "2 for LiveOutWorkOut\n";
	cout << "3 for LiveOutWorkIn\n";
	cout << "4 for LiveInWorkOut\n";
    cin >> Selection;
	
	switch (Selection) {
		case 1:
			mTaxRate= .016; // this is the line that has the error
			break;
		case 2:
			mTaxRate= 0;  // this is the line that has the error
			break;
		case 3:
			mTaxRate= .006;  // this is the line that has the error
			break;
		case 4:
			mTaxRate= .006;  // this is the line that has the error
			break;

	return mTaxRate;
}
}
closed account (D80DSL3A)
Line 15: float mTaxRate(void); you have indeed declared mTaxRate to be a function, so you can't do what lines 36, etc. are attempting.

Your class has no data members. Perhaps you meant to declare mTaxRate as a variable instead?
omit the (void) part from line 15 if so.
Topic archived. No new replies allowed.