cout is ambigious help pls

why suddenly my code is showing cout is ambiguous..help pls
I am going to guess and say you are using cout outside of a function which can cause similar errors, but it could be several other things too.

Posting some actual code would be helpful.
ists solve but i have another problem now...

what means by missing storage class...
Posting some actual code would be helpful.
okie heres the code...
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
#include <iostream>
#include <string>
#include "Header.h"
using namespace std;

class Account{
private:
	string firstname;
	string lastname;
	int accountnumber;
	double balance;
public:
	Account();
	Account(string fName,string lName,int accno,double bal);
	void setAccountNumber(int accno);
	void setBalance(double bal);
	void setWithdraw(int wdraw,double bal);
	void setDeposit(int dep,double bal);
	string getFullName(string fName,string lName);
	void display(string fName,string lName);

};

Account::Account(){
	firstname="Raaj";
	lastname="Lokanathan";
	accountnumber=5671;
	balance=0.0;
}

Account::Account(string fName,string lName,int accno,double bal){
	firstname = fName;
	lastname = lName;
	accountnumber = accno;
	balance = bal;
}

void Account::setAccountNumber(int accno){
	accountnumber = accno;
}

void Account::setBalance(double bal){
	balance = bal;
}

void Account::setWithdraw(int wdraw,double bal){
	if(bal>=wdraw){
		wdraw=bal-wdraw;
		cout<<"Your current balance is: "<<wdraw<<endl;
	}else{
		cout<<"No money"<<endl;
	}
}

void Account::setDeposit(int dep,double bal){
	dep=dep+bal;
	cout<<"Your current balance is: "<<dep<<endl;
}

string Account::getFullName(string fName,string lName){
	string FullName,x=" ";
	lName=x+lName;
	return FullName=fName+lName;
}

void Account::display(string fName,string lName){
	cout<<"First Name: "<<fName<<endl;
	cout<<"Last Name: "<<lName<<endl;
	cout<<"Full Name: "<<getFullName(fName,lName)<<endl;
	cout<<"Account Number: "<<accountnumber<<endl;
	cout<<"Current Balance: "<<balance<<endl;
}

class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(fName,lName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit();
};

void CurrentAccount::setOverdraftLimit(double overd){
	double bal;
	double wdraw;
	if(bal==0){
		if(bal>=overd){
			wdraw=bal-wdraw;
			cout<<"The revised balance is"<<wdraw<<endl;
		}else{
			cout<<"You cant access this funtion currently"<<endl;
		}
	}

double CurrentAccount::getOverdraftLimit(){
	return overd;
}

void main(){ 
	Account Acc;
	Account acc[5];
	CurrentAccount curr;
	string first_name;
	string last_name;
	int acc_no,choice,Wdraw,Dep,chose;
	double bAl,Overd;
	int i;
	cout<<"-------------------------------"<<endl;
	cout<<"Welcome to Raaj Banking System"<<endl;
	cout<<"-------------------------------"<<endl;
	cout<<"Choose your account type below:"<<endl;
	cout<<"(1) Current Account"<<endl;
	cout<<"(2) Saving Account"<<endl;
	cout<<"Choose wisely: ";
	cin>>chose;
	switch (chose){
	case 1:
		curr.CurrentAccount();
		cout<<"Please enter the amount you wish to withdraw: ";
		cin>>wdraw;
		curr.setOverdraftLimit(Overd);
		break;
	case 2:
		cout<<"EXIT"<<endl;
		break;
	}
	for(i=0;i<5;i++){
		cout<<"Please enter the details for the customer: "<<i+1<<endl;
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cin.ignore();
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		cout<<"----------------------------------------------------"<<endl;
		Acc.getFullName(first_name,last_name);
		Acc.setAccountNumber(acc_no);
		Acc.setBalance(bAl);
		Acc.display(first_name,last_name);
		cout<<"----------------------------------------------------"<<endl;
		cout<<"Please choose an option: "<<endl;
		cout<<"(1) Withdraw"<<endl;
		cout<<"(2) Deposit"<<endl;
		cout<<"(3) EXIT"<<endl;
		cout<<"-----------------------------------------------------"<<endl;
		cout<<"Please enter your choice: ";
		cin>>choice;
		switch(choice){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Acc.setWithdraw(Wdraw,bAl);
			break;
		case 2:
			cout<<"Please enter the amount you wish to deposit: ";
			cin>>Dep;
			Acc.setDeposit(Dep,bAl);
			break;
		case 3:
			cout<<"Try again"<<endl;
			break;
		} 
	}

	system("pause");

}
You are missing a closing brace on your setOverdraftLimit function.

The variable names you are accepting in your CurrentAccount constructor need to match what you are passing into the Account constructor. For example FName != fName.
 
CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(fName,lName,accno,bal)


You don't have a constructor defined that takes no arguments right now.
CurrentAccount curr;

You have a few more errors but they are pretty simple to understand from your compiler.
Last edited on
mr James2250 tq very much... for your help if i have any other problem i will post here
there is another simple error...
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
#include <iostream>
#include <string>
#include "Header.h"
using namespace std;

class Account{
private:
	string firstname;
	string lastname;
	int accountnumber;
	double balance;
public:
	Account();
	Account(string FName,string LName,int accno,double bal);
	void setAccountNumber(int accno);
	void setBalance(double bal);
	void setWithdraw(int wdraw,double bal);
	void setDeposit(int dep,double bal);
	string getFullName(string fName,string lName);
	void display(string FName,string LName);

};

Account::Account(){
	firstname="Raaj";
	lastname="Lokanathan";
	accountnumber=5671;
	balance=0.0;
}

Account::Account(string FName,string LName,int accno,double bal){
	firstname = FName;
	lastname = LName;
	accountnumber = accno;
	balance = bal;
}

void Account::setAccountNumber(int accno){
	accountnumber = accno;
}

void Account::setBalance(double bal){
	balance = bal;
}

void Account::setWithdraw(int wdraw,double bal){
	if(bal>=wdraw){
		wdraw=bal-wdraw;
		cout<<"Your current balance is: "<<wdraw<<endl;
	}else{
		cout<<"No money"<<endl;
	}
}

void Account::setDeposit(int dep,double bal){
	dep=dep+bal;
	cout<<"Your current balance is: "<<dep<<endl;
}

string Account::getFullName(string FName,string LName){
	string FullName,x=" ";
	LName=x+LName;
	return FullName=FName+LName;
}

void Account::display(string FName,string LName){
	cout<<"First Name: "<<FName<<endl;
	cout<<"Last Name: "<<LName<<endl;
	cout<<"Full Name: "<<getFullName(FName,LName)<<endl;
	cout<<"Account Number: "<<accountnumber<<endl;
	cout<<"Current Balance: "<<balance<<endl;
}

class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit(double overd);
	void displa();
};

void CurrentAccount::setOverdraftLimit(double overd){
	double bal;
	double wdraw;
	if(bal==0){
		if(bal>=overd){
			wdraw=bal-wdraw;
			cout<<"The revised balance is"<<wdraw<<endl;
		}else{
			cout<<"You cant access this funtion currently"<<endl;
		}
	}
}
double CurrentAccount::getOverdraftLimit(double overd){
	return overd;
}

int main(){ 
	Account Acc;
	Account acc[5];
	CurrentAccount Curr;
	string first_name;
	string last_name;
	int acc_no,choice,Wdraw,Dep,chose;
	double bAl,Overd;
	int i;
	cout<<"-------------------------------"<<endl;
	cout<<"Welcome to Raaj Banking System"<<endl;
	cout<<"-------------------------------"<<endl;
	cout<<"Choose your account type below:"<<endl;
	cout<<"(1) Current Account"<<endl;
	cout<<"(2) Saving Account"<<endl;
	cout<<"Choose wisely: ";
	cin>>chose;
	for(i=0;i<5;i++){
		switch (chose){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Curr.setOverdraftLimit(Overd);
			break;
		case 2:
			cout<<"EXIT"<<endl;
			break;
		}
	}
	for(i=0;i<5;i++){
		cout<<"Please enter the details for the customer: "<<i+1<<endl;
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cin.ignore();
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		cout<<"----------------------------------------------------"<<endl;
		Acc.getFullName(first_name,last_name);
		Acc.setAccountNumber(acc_no);
		Acc.setBalance(bAl);
		Acc.display(first_name,last_name);
		cout<<"----------------------------------------------------"<<endl;
		cout<<"Please choose an option: "<<endl;
		cout<<"(1) Withdraw"<<endl;
		cout<<"(2) Deposit"<<endl;
		cout<<"(3) EXIT"<<endl;
		cout<<"-----------------------------------------------------"<<endl;
		cout<<"Please enter your choice: ";
		cin>>choice;
		switch(choice){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Acc.setWithdraw(Wdraw,bAl);
			break;
		case 2:
			cout<<"Please enter the amount you wish to deposit: ";
			cin>>Dep;
			Acc.setDeposit(Dep,bAl);
			break;
		case 3:
			cout<<"Try again"<<endl;
			break;
		} 
	}

	system("pause");

}

the bold one is the error
your class CurrentAccount needs a default constructor.
CurrentAccount::CurrentAccount() {} //default ctor that does nothing
Otherwise the compiler doesn't know what to do to create 'curr' without a list of arguments.
Last edited on
well this is solve i am getting another silly error error 2065 'first_name' undeclared identifier and also another one error 2065 'last_name' undeclared identifier
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
178
179
180
181
182
183
184
185
186
187
#include <iostream>
#include <string>
#include "Header.h"
using namespace std;

class Account{
private:
	string firstname;
	string lastname;
	int accountnumber;
	double balance;
public:
	Account();
	Account(string FName,string LName,int accno,double bal);
	void setAccountNumber(int accno);
	void setBalance(double bal);
	void setWithdraw(int wdraw,double bal);
	void setDeposit(int dep,double bal);
	string getFullName(string fName,string lName);
	void display(string FName,string LName);

};

Account::Account(){
	firstname="Raaj";
	lastname="Lokanathan";
	accountnumber=5671;
	balance=0.0;
}

Account::Account(string FName,string LName,int accno,double bal){
	firstname = FName;
	lastname = LName;
	accountnumber = accno;
	balance = bal;
}

void Account::setAccountNumber(int accno){
	accountnumber = accno;
}

void Account::setBalance(double bal){
	balance = bal;
}

void Account::setWithdraw(int wdraw,double bal){
	if(bal>=wdraw){
		wdraw=bal-wdraw;
		cout<<"Your current balance is: "<<wdraw<<endl;
	}else{
		cout<<"No money"<<endl;
	}
}

void Account::setDeposit(int dep,double bal){
	dep=dep+bal;
	cout<<"Your current balance is: "<<dep<<endl;
}

string Account::getFullName(string FName,string LName){
	string FullName,x=" ";
	LName=x+LName;
	return FullName=FName+LName;
}

void Account::display(string FName,string LName){
	cout<<"First Name: "<<FName<<endl;
	cout<<"Last Name: "<<LName<<endl;
	cout<<"Full Name: "<<getFullName(FName,LName)<<endl;
	cout<<"Account Number: "<<accountnumber<<endl;
	cout<<"Current Balance: "<<balance<<endl;
}

class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount();
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit(double overd);
	void display();
};

CurrentAccount::CurrentAccount(){
	overdraftlimit=0.0;
}

CurrentAccount::CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
	overdraftlimit=overd;
}

void CurrentAccount::setOverdraftLimit(double overd){
	double bal=0;
	double wdraw;
	if(bal==0){
		if(bal>=overd){
			wdraw=bal-wdraw;
			cout<<"The revised balance is"<<wdraw<<endl;
		}else{
			cout<<"You cant access this funtion currently"<<endl;
		}
	}
}
double CurrentAccount::getOverdraftLimit(double overd){
	return overd;
}
void CurrentAccount::display(){
	Account::display(string FName,string LName);
}
int main(){ 
	Account Acc;
	Account acc[5];
	CurrentAccount Curr;
	string first_name;
	string last_name;
	int acc_no,choice,Wdraw,Dep,chose;
	double bAl,Overd;
	int i;
	cout<<"-------------------------------"<<endl;
	cout<<"Welcome to Raaj Banking System"<<endl;
	cout<<"-------------------------------"<<endl;
	cout<<"Choose your account type below:"<<endl;
	cout<<"(1) Current Account"<<endl;
	cout<<"(2) Saving Account"<<endl;
	cout<<"Choose wisely: ";
	cin>>chose;
	for(i=0;i<5;i++){
		switch (chose){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Curr.setOverdraftLimit(Overd);
			break;
		case 2:
			cout<<"EXIT"<<endl;
			break;
		}
	}
	for(i=0;i<5;i++){
		cout<<"Please enter the details for the customer: "<<i+1<<endl;
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cin.ignore();
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		cout<<"----------------------------------------------------"<<endl;
		Acc.getFullName(first_name,last_name);
		Acc.setAccountNumber(acc_no);
		Acc.setBalance(bAl);
		Acc.display(first_name,last_name);
		cout<<"----------------------------------------------------"<<endl;
		cout<<"Please choose an option: "<<endl;
		cout<<"(1) Withdraw"<<endl;
		cout<<"(2) Deposit"<<endl;
		cout<<"(3) EXIT"<<endl;
		cout<<"-----------------------------------------------------"<<endl;
		cout<<"Please enter your choice: ";
		cin>>choice;
		switch(choice){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Acc.setWithdraw(Wdraw,bAl);
			break;
		case 2:
			cout<<"Please enter the amount you wish to deposit: ";
			cin>>Dep;
			Acc.setDeposit(Dep,bAl);
			break;
		case 3:
			cout<<"Try again"<<endl;
			break;
		} 
	}

	system("pause");

}

Okay, a few things.

Firstly, you define a constructor twice (which should be throwing a compiler error as well)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount();
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit(double overd);
	void display();
};

CurrentAccount::CurrentAccount(){
	overdraftlimit=0.0;
}

CurrentAccount::CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
	overdraftlimit=overd;
} //will throw compiler error, multiple definition of constructor. 

You need only one definition for that constructor, but not both.


Secondly, on line 110, you have an error in your display function (which should also be throwing a compiler error). You're trying to use a variable declaration as an expression. What I believe you're trying to accomplish is the following:
1
2
3
4
void CurrentAccount::display() {
    display(this->firstname, this->lastname); //pass display firstname and lastname variables that already
    //exist as members of the class.
}
Last edited on
Topic archived. No new replies allowed.