How do I return a reference to a newly instantiated class/object from a singleton object?
Posted on 2014-11-14
I have a singleton class that is managing the CRUD of my customer data. The singleton exposes a GetCustomer which is to return the memory location of the retrieved customer. What I am getting back from GetCustomer is an entire customer object not just a reference to the newly created memory location inside the singleton.
How do I get a handle/reference on the memory location created by GetCustomer?
public Customer GetCustomer(int customerID)
//if customer exists, return referenceexisting customer
//if customer doesn't exist in Singleton, then retrieve customer data from database and put in Singleton's list of // customers
Customer newcust = new Customer();
private Customer localCust;
localCust = GetCustomer(int custID);
When I make changes to the memory space for the customer object created by my singleton, those changes are not reflected in my localCust.