invalid use of member

I am getting this error Compiler Output:
0IGzNLUq.c: In constructor 'CheckingAccount::CheckingAccount(int, float, float)':
0IGzNLUq.c:104: error: invalid use of member (did you forget the '&' ?)

and I have tried about 100 times to fix it and google how to fix it and I have no clue... Can someone see what I am missing?

Also I know I have 4 unused variables but I have not wrote the main yet to put them in I wanted to get this straight first. Thank you very much.


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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>

using std::cout;
using std:: cin;
using std:: endl;
using namespace std;


class BankAccount  //BankAccount - Base Class 

{
protected:
	float  balance ;
	float getBalance (void) ;


private:
	
	string AccountType;
	

public:
	int amount;
	void deposit (float);
	void withdrawal (float );
	void displayAccount (int);
	~BankAccount();
	double setAccountNumber () const; 
    int AccountNum  (void);





};
/////////////////////////////////////////////////////////////////////

//CheckingAccount - Derived Class
class CheckingAccount: public BankAccount
{
private:
	float Charge;
	
	


public:
	~CheckingAccount();
	CheckingAccount (void);
	CheckingAccount ( int, float, float);
void withdrawal (float);

};
////////////////////////////////////////////////////////////////////

//SavingsAccount - Derived Class
class SavingsAccount: public BankAccount
{
private:
	float int_rate;
	void getRate(int);
	

public:
	~SavingsAccount();
	SavingsAccount ( void ); // Default constructor
	SavingsAccount ( int, float, float );
	void add_interest ( void ); // Add interest to balance
	void withdrawal ( float );
	double InterestRate ;
void deposit (float);
};


///////////////////////////////////////////////////////////
float BankAccount:: getBalance (void)
{
	return ( balance);
}
/////////////////////////////////////////////////////
void BankAccount::deposit (float amount)
{
	balance=  balance- amount;
}
////////////////////////////////////////////////////
void BankAccount::withdrawal(float amount)

	{
		balance = balance+ amount;
	}


	//////////////////////////////////////////////////////
	//CheckingAccount Definition
	
CheckingAccount::CheckingAccount ( void ) // Default constructor
	{
		int AccountNum = 65432;
		balance = 100.00;
		Charge = 0.50;
	}
	CheckingAccount::CheckingAccount ( int AccountNum = 65432, float bal = 100.00, float chg = 0.50 )
	{
        setAccountNumber = AccountNum ;
		balance = bal;
		Charge = chg;
	}
	
	
////////////////////////////////////////////////////////
void CheckingAccount::withdrawal (float amount)
{
	if ((BankAccount::getBalance() - amount) >= 0)
	{
		BankAccount::withdrawal (amount);
	}
	else
	{
		cout <<"Insufficient Fund for transaction";
		cout<< endl;
	}
}

	//////////////////////////////////////////////////////////

SavingsAccount::SavingsAccount ( int acct_no = 54321, float balance = 100.0, float rate = 3.0 ) 

	{
		int AccountNum = 54321;
		balance = 100.0;
		float InterestRate = 3.0;
	
	}
	
	void SavingsAccount::add_interest ( void ) // Add interest
	{
		
		InterestRate = balance * ( int_rate * 0.01 / 365 );
		balance= InterestRate + balance;
	}
	
	/////////////////////////////////////////////////////////////////
	void SavingsAccount :: withdrawal (float amount)
	{
		if 
	
			(balance - amount >=0)
 
				balance =(BankAccount::getBalance() + (InterestRate * BankAccount :: getBalance() ) );
		
		else 
		
			cout<< "Insufficient funds for transaction ";
			cout << endl;
		}
		/////////////////////////////////////////////////////
		void SavingsAccount :: deposit (float amount)
		{
		
			balance =(BankAccount :: getBalance() + ( InterestRate * BankAccount::getBalance() ) );
		}
/////////////////////////////////////////////////////////////////////////////////////
int main()
{
return 0 ;
}










setAccountNumber is a function. You can't add an integer to a function - that's not valid C++.
Okay, but I have changed it a lot in the scope to try to get it to read AccountNum like it did for Charge and balance by using (float), char... a couple others that I knew weren't going to work like int, double, double amount.... So how do I properly declare it?

I want it to read setAccountNumber = AccountNum

or do I not need to set an account number if I made AccoutNum = 65432?

Is setAccountNumber used if I was asking someone to set an account number?

The directions just say to set the account number not to ask the user to do so... See I'm starting to get myself confused...
Last edited on
closed account (Dy7SLyTq)
>setAccountNumber is a function. You can't add an integer to a function - >that's not valid C++.
sure you can. you can also make a function an lvalue in an assignment expression. ie f() = 10
@DTSCode: the issue is the missing argument list. Without the argument list, you refer to the function, rather than calling it and referring to its return value.
closed account (Dy7SLyTq)
i know. that was the only thing i had read and would like to correct him
i know. that was the only thing i had read and would like to correct him

But your correction was not correct. You may not add a value to a function. You may add a value to something a function returns, provided it returns something for which that would make sense.
Last edited on
setAccountNumber function is declared as a const function which is peculiar. Normally a function with that kind of name is expected to change something. I would expect an account number attribute with declarations like this.

1
2
3
4
5
6
7
8
9
// Of course your account number type could also be a string or double or whatever you wish to design
void setAccountNumber(int value);
int getAccountNumber() const;  // use const for accessors, but not mutators
int accountNumber;

// to invoke (very generic code - you'd substitute your actual type and function names)
AccountType account;
account.setAccountNumber(value);  // write the value into the object so it cannot be const function
int number = account.getAccountNumber(); // guaranteed not to change the object because it is const function 
Last edited on
Not only that, it is returning a double, and is has no definition.
Topic archived. No new replies allowed.