Vector Problem

Hi,

This is my first attempt at using vectors and I must confess that I am a bit lost.

I have created a class that will manage bank accounts and I am trying to create a vector of objects that will contain each customer's details. At present I am trying to create a vector that when called will allow me to enter a new customer's name, create an account number and set their balance but don't know what to do next. I have created member variables that would do this for each object and that works but I know that I don't need these mutator functions and I need to add them to my vector.

Any help would be appreciated

Here is my code so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <cstdlib>
#include <string>
#include <sstream>

using namespace std;

//Start of class BankAccount

class BankAccount
{
	public:
		BankAccount (string, string, double);//declaring overload constructor 
		~BankAccount ();//declaring destructor
		//Accessor Functions
                string get_name () const;
                string get_account_number () const;
                double get_balance () const;
		//Mutator Functions
		void set_customers_name ();
                void set_account_number ();
                void set_balance ();
				
	private:
		static int number_of_accounts_created;
		string new_customers_fullname;
		string new_account_number;
		double new_balance;
		double new_deposit;
		double new_withdrawl;
		double new_interest;
};//end of class declaration

BankAccount::BankAccount (string customers_fullname, string account_number, double balance)
{
    number_of_accounts_created++;                   
    new_customers_fullname = customers_fullname;
    new_account_number = account_number;
    new_balance = balance;               
}//end of constructor

BankAccount::~BankAccount ()
{
}//end of destructor

//member function that allows the customer's fullname to be set
void BankAccount::set_customers_name()
{
	string first_name, last_name;
	cout << "Please enter new customer's first name: ";
	cin >> first_name;
	cout << "Please enter new customer's last name: ";
	cin >> last_name;
	customers_fullname = first_name + " " + last_name;	
}//end of member function

//member function that returns customer's fullname
string BankAccount::get_name() const
{
	return customer_fullname;
}//end of member function

//member function that creates customer's account number
void BankAccount::set_account_number ()
{
	int last_six_digits = 112280 + number_of_accounts_created;
	cout << "Number of accounts created: " << number_of_accounts_created;
	ostringstream convert;
	convert << last_six_digits;
	string first_two_digits = "00";
	account_number = first_two_digits + convert.str();
}//end of member function

//member function that returns the customer's account number
string BankAccount::get_account_number () const
{
	return account_number;
}//end of member function

//member function that sets customer's initial balance
void BankAccount::set_balance ()
{
     cout << "Please enter customer's balance: ";
     cin >> new_balance;
}//end of member function

//member function that returns customer's initial balance
double BankAccount::get_balance () const
{
     return new_balance;       
}//end of member fucntion

//End of class BankAccount
//******************************************************************************

//Start of Vector declaration

void create_accountVector (vector <Student>&);

//End of Vector declaration
//******************************************************************************

//Global variables
int Customer::number_of_accounts_created = 0;//initialising variable

//End of Global variables
//******************************************************************************

int main ()
{
    vector <BankAccount> myAccount;//vector declaration	
    
    create_accountVector(myAccount);//vector call
    system ("PAUSE");
    return 0;
}//end of main

//Start of vector definitions

//Vector that creates account for new customer
void create_accountVector (vector <BankAccount>& new_myAccount)
{
     string first_name, last_name;
     string customers_fullname, account_number;
     cout << "Please enter new customer's first name: ";
     cin >> first_name;
     cout << "Please enter new customer's last name: ";
     cin >> last_name;
     customers_fullname = first_name + " " + last_name;
     BankAccount newCustomer(customers_fullname, account_number, balance);
     new_myAccount.push_back(newCustomer);
     cout << endl;  
}
Topic archived. No new replies allowed.