Getting Runtime error

Here is the link for the complete code

http://ideone.com/AY0eEP

The main problem is with calling getReportedEmployees() function. On CodeBlocks I am getting an empty list on calling this function. How to resolve this ?



> Employee *emp6 = new Employee;
http://www.cplusplus.com/forum/general/138037/
also, you could simply use an array


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    unordered_map<int, Employee*> storeData(Employee *emp, int parseInt)
    {
        data.insert ( std::pair<int,Employee*>(parseInt,emp) );

        Employee *empl; //unitialised

        if(data.find(emp->getManagerId()) != data.end()) //¿what if this fails?
            empl = data.find(emp->getManagerId())->second;

        if(empl->getId()!=emp->getId()) //empl would be invalid
            empl->getReportedEmployees().push_back(emp);



        return data;
    }
you are inserting the pair {parseInt, emp} but searching for the key 'emp->getManagerId()'
You never set the `manager_id' for `emp10'
(check out about constructors)
Topic archived. No new replies allowed.