Hello everyone! I've read a lot of articles on DaniWeb and I've decided to join your community!
I have a university project to make a bank account system, which consists of at least 10 account classes, and 3 of them inherit from at least 2 other. The system has 1 base account "Account" and all other classes inherit from it. I'd like to share with you guys my progress and if anyone has any suggestions, please do post and let me know...
So far, my ideas are of classes - Account, SavingsAccount, Salary account, CardAccount, NetworkAccount, SharedAccount(so multiple people can withdraw money) ... and I am out of account ideas for now! If you have any let me know :)
I've just started and I have the Account class defined as follows
Account.h
#include <iostream>
#include "string"
using namespace std;
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account {
public:
Account();
int deposit(int);
int withdraw(int);
void account_balance()const;
private:
float balance;
};
#endif
Account.cpp
#include "Account.h"
#include <iostream>
using namespace std;
Account::Account() {balance = 0.0;}
int Account::deposit(int amount){
balance += amount;
return balance;
}
int Account::withdraw(int amount){
balance -= amount;
return balance;
}
void Account::account_balance()const{
cout<<balance;
}
And I have a main to test the account class
main.cpp
#include <iostream>
#include "Account.h"
using namespace std;
int main()
{
Account *acc;
acc = new Account;
acc->deposit(23);
acc->account_balance();
cout<<endl;
acc->withdraw(12);
acc->account_balance();
return 0;
}
I am wondering now if I need an interest method, to calculate different interest for different accounts?
I will put the implementation of the other classes as soon as possible! I hope if I get into a trouble with inheritance someone will be able to help me out :)