Basically, my proggramme is
CLASS ACCOUNT DEFINITION
class Account
{
public:
Account();
void setBalance(int);
void getBalance();
private:
int balance;
}
CLASS ACCOUNT IMPLEMENTATION
#include <iostream>
#include "account.h"
using namespace std;
Account::Account()
{
}
void Account::getBalance()
{
cout << balance;
}
void Account::setBalance(int ammount)
{
balance = ammount;
}
MAIN
#include <iostream>
#include "account.h"
using namespace std;
int main()
{
Account obj[10];
int flag = 0;
int id;
int ammount;
char more;
while(flag == 0)
{
Account acc;
cout << "Enter account number: ";
cin >> id;
cout << "Enter ammount: ";
cin >> ammount;
acc.setBalance(ammount);
obj[id] = acc;
cout << "Create more? (y/n)";
cin >> more;
if (more == 'n')
{
flag = 1;
}
}
return 0;
}
The problem is, it can only create an array of 10 account objects. How can I use dynamic memory so it can create an undefined array of account objects. Please assist me.
Thank you