-2
class Bank {
private:
         Customer customers;
          int numberOfCustomers[];

public:
          addCustomer (std::string f, std::string l);
          int getNumOfCustomer()const;
          Customer getCustomer(int index);
};
  1. Add two attributes to the Bank class: customers (an array of Customer objects) and numberOfCustomers (an integer that keeps track of the next customers array index).
  2. Add a public constructor that initializes the customers array with some appropriate maximum size (at least bigger than 5).
  3. Add the addCustomer method. This method must construct a new Customer object from the parameters (first name, last name) and place it on the customers array. It must also increment the numberOfCustomers attribute.
  4. Add the getNumOfCustomers accessor method, which returns the numberOfCustomers attribute.
  5. Add the getCustomer method. This method returns the customer associated with the given index parameter.
  • 2
    No it's full of syntactical and semantical errors. – πάντα ῥεῖ Jun 05 '22 at 05:07
  • This is a great example of why questions should be self-contained: That link is a 404 error. – Nathan Pierson Jun 05 '22 at 05:10
  • Add two attributes to the Bank class: customers (an array of Customer objects) and numberOfCustomers (an integer that keeps track of the next customers array index). Add a public constructor that initializes the customers array with some appropriate maximum size (at least bigger than 5). Add the addCustomer method. This method must construct a new Customer object from the parameters (first name, last name) and place it on the customers array. It must also increment the numberOfCustomers attribute. – Mardilyn Oboy Jun 05 '22 at 05:12
  • Add the getNumOfCustomers accessor method, which returns the numberOfCustomers attribute. Add the getCustomer method. This method returns the customer associated with the given index parameter. – Mardilyn Oboy Jun 05 '22 at 05:12
  • 1
    Information necessary to understand the question should be edited into the question, not posted as comments. – Nathan Pierson Jun 05 '22 at 05:13
  • Getting specifically into the problems with this code: You do not have an array of Customers, you have a single Customer object. You do not have a single int numberOfCustomers, you nearly have an array but you didn't provide it a size, which is invalid. You did not declare a default constructor, and the one the compiler generates for you will not have the appropriate behavior automatically. The addCustomer method doesn't have a return type. – Nathan Pierson Jun 05 '22 at 05:19
  • Furthermore, while the previous are all definite errors that will prevent this header from compiling at all and/or definitely not meet the stated requirements of the exercise, there is a relatively minor issue: `getCustomer` should probably be `const`, and/or there should be both a `const` and a non-`const` overload that return by `const` reference and non-`const` reference, respectively, instead of by value. Step 5 is somewhat underspecified in my opinion. – Nathan Pierson Jun 05 '22 at 05:22

0 Answers0