I'm writing part of a customer database that handles making new customers and selling them items. In "Customer.h", I have the struct:
struct Customer {
    String name;
    int bottles;
    Customer(String);
    Customer(void) { name = "__invalid__"; }
};
I have a class in the file "CustomerDB.h"
class CustomerDB {
private:
    Customer* data; // an array of Customer objects (allocated on the heap)
    int capacity; // size of the array on the heap
    int length; // number of valid customers actually in the array
public:
    CustomerDB(void);
There's a constructor, in "CustomerDB.cpp"
Customer::Customer(string name) {
    this->bottles = 0;
    this->name = name;
}
I create *an object in another function (which is in "CustomerDB.cpp")
Customer& CustomerDB::operator[](string name) {
     Customer Customer(name); 
     return Customer;
And there's an object of CustomerDB:
CustomerDB database; (Which is in another cpp file which handles the purchases).
The string input works. The object is created. There's no issues there. So I have 2 problems, one of which is because of the other.
- I need to make a new non-Local Customer object in this function (stored into the non-Local Database), and
- Return the reference to it. But the constructor I just called doesn't give me a reference. It just makes it, as it should. I'm unintentionally making a local object instead of one that's added to the "main" database. As a result, the reference is nothing useful.
If I try return Customer; it says that "Customer does not refer to a value."
Any help/advice is appreciated.
 
    