I decided to simplify things by including everything in one file for now. I have one last error in the program i con-t figure out.
Code:
//bank account prblm #1 c++ primer plus
#include <iostream>
#include <cstring>
using namespace std;
class Account
{
private:
char name[40];
char acctnum[25];
double balance;
public:
Account(char * client, char * num, double bal=0.0);
void set(void);
void show(void) const;
void deposite(double cash);
void withdraw(double cash);
~Account();
};
// class constructor
Account::Account(char * client, char * num, double bal)
{
strncpy(name,client,40);
name[40]='\0';
strncpy(acctnum,num,25);
acctnum[25]='\0';
balance=bal;
}
void Account::set()
{
strncpy(name,"John Doe\0",40);
strncpy(acctnum,"0\0",25);
balance=0.0;
}
void Account::show() const
{
cout << "Name:" << name
<< "\t Account ID:" << acctnum
<< "\n\t Balance:" << balance;
}
void Account:: deposite(double cash)
{
balance+=cash;
}
void Account::withdraw(double cash)
{
double temp;
temp=balance;
if (temp-cash<0)
{
cout << "You do not have enough money in your account!\n";
}
else
{
balance-=cash;
}
}
// class destructor
Account::~Account(){}
int main()
{
double deposit=0.0;
double withdra=0.0;
Account checking=("Troy","A609",12.25);\\line 74 error here???
checking.show();
checking.set();
checking.show();
cout << "Enter deposite:";
cin >> deposit;
checking.deposite(deposit);
cout << endl;
checking.show();
cout << "Enter withdrawl:";
cin >> withdra;
checking.withdraw(withdra);
cout << endl;
checking.show();
return 0;
}
C:\Borland\BCC55\src>bcc32 bankh.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
bankh.cpp:
Error E2034 bankh.cpp 74: Cannot convert 'double' to 'Account' in function main(
)
*** 1 errors in Compile ***