troubleshooting Question

Add object to separate arrays

Avatar of flexlight
flexlight asked on
C++
17 Comments2 Solutions274 ViewsLast Modified:
I have one class object (an employee object for instance), and I want to add this object to two separate arrays in my program (array in store class and array in chain class both implemented by template).
I wrote this code:

void Chain::addEmployee(Employee *to_put,int s_loc)
{
      chain_emps.addObj(to_put); //add object to array in chain class
      (*(chain_stores.getObj(s_loc))).addEmployee(to_put); // add object to array in store class
}

void Store::addEmployee(Employee *to_put)
{
      store_emps.addObj(to_put);
}

when I run this program I get a runtime error..
what's the problem...?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 17 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros