I am having severe issues with preprocessor commands.
I have 3 files
- account.h
- account.cpp
- bank.cpp
bank.cpp makes use of account as a class.
I just end up with a ton of errors every time I compile (they seem like they could fill a post on their own)
Here is account.h
Here is account.cppCode:#ifndef _Account_ #define Account class Account { double money; // amount of money held by this account double interestRate; // a monthly or yearly interestrate, depending on how the account is to be used. public: // create an account with an initial amountand a specified interest rate Account(double amount, double percent); // return the account's balance double balance(); // add money to the account void deposit(double); // substract money from the account void withdraw(double); // add money according to the interest rate. void addInterest(); }; #endif
And here is bank.cppCode:#include "account.h" // create an account with an initial amountand a specified interest rate Account(double amount, double percent) { money = amount; interestRate = percent; } // return the account's balance double balance() { return money; } // add money to the account void deposit(double amount) { money += amount; } // substract money from the account void withdraw(double amount) { money -= amount; } // add money according to the interest rate. void addInterest() { money *= (1 + interestRate/100.0); // this, ofcourse, is the same as money = money * (1 + (interestRate/100) ); }
Any help with this issue would be really appreciated!Code:#include <iostream> #include "account.cpp" using namespace std; void main(void) { Account stdAccount(100, 4); // create an account with £100and 4% interest rate stdAccount.addInterest(); cout << "Balance: " << stdAccount.balance()<< endl; stdAccount.deposit(50); cout << "Balance: " << stdAccount.balance()<< endl; stdAccount.withdraw(100); cout << "Balance: " << stdAccount.balance()<< endl; int i; cin >> i; }
The errors that appear to begin with are
Error 1 error C2062: type 'double' unexpected d:\users\tom\documents\visual studio 2008\projects\bank\bank\account.h 14
Error 3 error C2062: type 'double' unexpected d:\users\tom\documents\visual studio 2008\projects\bank\bank\account.cpp 6
Error 11 error C2062: type 'double' unexpected d:\users\tom\documents\visual studio 2008\projects\bank\bank\account.h 14
Error 13 error C2062: type 'double' unexpected d:\users\tom\documents\visual studio 2008\projects\bank\bank\account.cpp 6
Thanks for reading my post
/Sed



LinkBack URL
About LinkBacks


