You store a pointer to the reference of an object. But that object gets dereferenced when you leave your first function, so you table points to uninitialized memory. I would advise not to store data with pointers, but use emplace
methods to avoid making copies.
std::list<std::pair<std::string, StudentRecord*>*>
does not own the objects it points to, just the pointer.
You have to make a copy, you can enforce this by changing the type to:
std::list<std::pair<std::string, StudentRecord*>>
You will have to adapt your m_Table type as well, from your example I cannot see what it is.
If you want to keep the pointer then, you need to change
std::pair<std::string, StudentRecord*> ptr = { p_Name, p_StudentRecord };
to allocate the object on the heap, instead of the stack. (i.e. use new
)