-
Multi. source files?
I'm having problems with this program and it seems to be in my header file can anyone guide me in the right direction?
Code:
//Header file for Checking Account Program
//CheckAccount.h
class CheckAccount
{
Public:
CheckAccount (int date, string name, float balance);
void withdraw ()float;
void deposit ()float;
float CurrentBalance ();
Private:
AccountopenDate (y,m,d); //Considering a struct
AccountOwner(string name);
CurrentBalance(float balance);
};
Code:
//Implement
//CheckAccount.cpp
#include <iostream>
#include "CheckAccount.h"
using namespace std;
CheckAccount::CheckAccount(int date, string name, float balance)
{
AccountOpenDate = date;
struct AccountOpenDate
{
int year;
int month;
int day;
};
AccountOwner = name;
CurrentBalance = balance;
}
void CheckAccount::withdraw(float)
{
cout<<"Cash Amount Wanted: "<<endl;
cin>>w;
}
void CheckAccount::deposit(float)
{
cout<<"Amount Deposited: "<<endl;
cin>>d;
}
float ChechAccount::CurrentBalance(float)
{
Switch balance
{
case d:
CurrentBalance=balance+Deposit;
cout<<CurrentBalance;
break;
case w:
CurrentBalance=balance-Withdraw;
cout<<CurrentBalance;
break;
default:
cout<<"Error made"<<endl;
break;
};
}
Thank You.
-
The problem is that you capitalised 'public' and 'default'. Remember, C++ is a case-sensitive language meaning that Foo is not the same as foo nor FoO. There are many more mistakes, in fact. You are also capitalizing 'switch'. The worse thing you are doing is creating a structure inside the constructor... This has to be done outside of it. I really suggest you to read some basic book or tutorial because there are very very very basic mistakes there that you shouldn't be doing if you are touching classes and structs.
-
Start with an empty class and get it to compile before continuing. Then add a function, or a constructor, or a data member and get it to compile before continuing. Keep compiling after each step and fixing any errors that come up before moving on to the next piece of code.
-