473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how can i solve this error?

2 New Member
#include<iostream>
using namespace std;

class account
{
protected:
char name[40];
int account_id;
int account_type;
float initial_deposit;
public:

float withdraw;
float balance;
account();
void deposit()
{
float deposit;
cout<<"Enter Amount To DEPOSIT:"<<endl;
cin>>deposit;
balance+=deposit;
cout<<"Balance is: $"<<balance<<endl;
}
virtual void withdraw()=0;
};

account::account()
{
cout<<"Enter Account Holder Name:"<<endl;
cin>>name;
cout<<"Enter Account ID"<<endl;
cin>>account_id;
cout<<"Enter ACCOUNT TYPE (DEBIT=1,CREDIT=2)"<<endl;
cin>>account_type;
cout<<"Enter Initial Deposit"<<endl;
cin>>initial_deposit;
balance+=initial_deposit;
}

class debit:public account
{
void deposit();

void withdraw()
{
//float withdraw;
cout<<"Enter Amount To WITHDRAW:"<<endl;
cin>>withdraw;
if(withdraw<=balance)
{
amount-=withdraw;
cout<<"Balance is: $"<<balance<<endl;
}
else
{
cout<<"withdraw failed"<<endl;
cout<<"Balance Is: $"<<balance<<endl;
}
}
};

class credit:public account
{

void deposit();
/*{
cout<<"Enter Amount To DEPOSIT:"<<endl;
cin>>deposit;
balance+=deposit;
cout<<"Balance is: $"<<balance<<endl;
}*/
void withdraw()
{
//float withdraw;
int credit_limit=2000;
cout<<"Enter Amount To WITHDRAW:"<<endl;
cin>>withdraw;
if(withdraw<=(-credit_limit))
{
balance-=withdraw;
cout<<"Balance is: $"<<balance<<endl;
}
else
{
cout<<"withdraw failed"<<endl;
cout<<"Balance Is: $"<<balance<<endl;
}
}
};

int main()
{
int account_type=0;
cout<<"Start"<<endl;
account ob1;
debit ob2;
credit ob3;

account *p;
if(account_type=1) p=&ob2;
else if(account_type=2) p=&ob3;
else cout<<"Invalid Input For ACCOUNT TYPE"<<endl;

p->deposit();
p->withdraw();
return 0;
}
Dec 28 '10 #1
2 1991
Tayabur Rahman
2 New Member
error C2040: 'withdraw' : 'void (void)' differs in levels of indirection from 'float'
Dec 28 '10 #2
Robert Kulseth
2 New Member
I found a few problems with your code. The main problem is you have a name collision. You have a method withdraw and a public member variable withdraw in the same class. it's a good practice to prefix all your member variables with either an '_' or an 'm_'. This will fix most of your problems. you had two other errors that were pretty simple to fix. I compiled it on g++, but didn't run it. Also, you should encapsulate your member variables rather than expose them public. That way no one has to see your ugly 'm_' prefix for member variables. Good Luck.
Dec 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
1
by: Erland | last post by:
Hi all, I have made an ASP.NET 1.1 application on windows 2000 advanced server. In the application, i have saved the file using the following code string str; str="this is my data";...
1
by: rocksoft | last post by:
Hi, i got error "class not registered" when i try to create web setup and deployment project to my web application. i'm used Asp.net and c# to my application, i created web setup and deployment...
5
by: mickey22 | last post by:
Hi, I am getting some errors in building my project I tried to build a C++ file say abc.cpp and I have put the all the directories to include necessary library files and header files..But I...
0
by: winbala | last post by:
Hi, I am having problem creating new project using VS.Net 2003. Whenever I am trying to create new project (any type) it shows error message "Error writing the project file. Error loading...
1
by: sana krishna | last post by:
Hai, Pls anyone help me........................... I am using ASP.NET(C#). I want to display the data in a gridview and make the gridview to become editable and insert and delete. But i can't...
7
by: akmaRudiliyn | last post by:
Hai everybody :). I have problem and need help. ERROR: ERROR Violation of PRIMARY KEY constraint 'PK_Table1_01'. Cannot insert duplicate key in object 'dbo.table1'. ERROR The statement has...
5
by: despairingFreshman | last post by:
I've got the Warning : Microsoft.Performance : The 'this' parameter of '....' is never used.Mark the member as static or use this in the method body or at least one prperty accessor, if appropriate....
0
by: dbphydb | last post by:
Hi, The below code is doing the following 1. Reading the branch name and the destination from a txt file 2. Parsing thru HTML pages Basically, i want to deploy the build of the branch (supplied...
5
by: romiverma | last post by:
hi, i have used sql2000 stored procedure with 2 date parameters to create crystal report 8.5. when i am sending date parameters from vb6 and calling the report, its giving error "the specified value...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.