Btw below is the key parts of my code - not all as there are loads of lines:
//main.cpp
#include <iostream>
#include "Customer.h"
using namespace std;
void displayMainMenu();
int enterMainChoice();
void displayAccountMenu();
int enterAccountChoice();
int enterCustomerID();
Customer createCustomer();
void main(void)
{
unsigned short numberOfCustomers = 0;
Customer *Customers[10];
*Customers[numberOfCustomers] = createCustomer();
numberOfCustomers++;
}
Customer createCustomer()
{
string name;
int age;
cout << "\nPlease enter you name: ";
cin >> name;
cout << "Please enter you age: ";
cin >> age;
return Customer(name, age);
}
----------------
Below is just the main function from Customer.cpp
----------------
Customer::Customer(string name, int age)
{
this->name = name;
this->age = age;
}
Now it almost works. I can run it and it asks me for the information, but when it tries to add the actual customer is crashes in "xstring" with this error:
Unhandled exception at 0x643924f0 (msvcp90d.dll) in bankusingarrays.exe: 0xC0000005: Access violation reading location 0xcccccce8.
Now - I thought it would be because I am passing back something which can't be then put into the pointer array.
But I am not sure how to go about it - trying to create the object and store the address in the pointer array. I am pretty new with C++ so try and bare with me lol..
Thanks!