Welcome to the exciting world of C++!
Short answer: you’re passing Store as a value. All your menu functions should take a Store& or Store* instead.
When you’re passing Store as a value then an implicit copy is done (so the mainStore variable is never actually modified). When you return from the function the Store::~Store is called to clean up the copied data. This frees mainStore.bookList without changing the actual pointer value.
Further menu manipulation will corrupt memory and do many double frees.
HINT: If you’re on linux you can run your program under valgrind and it will point out most simple memory errors.
Related Posts:
- Why would we call cin.clear() and cin.ignore() after reading input?
- How to read groups of integers from a file, line by line in C++
- Using cin to input a single letter into a char
- Multiple inputs on one line
- Why use conio.h?
- What are the rules of the std::cin object in C++?
- std::cin.getline( ) vs. std::cin
- What is EOF in the C programming language?
- C++ round a double up to 2 decimal places
- When and why do I need to use cin.ignore() in C++?
- cin >> “no operator matches these operands”
- Press Enter to Continue
- cin >> “no operator matches these operands”
- Correct way to use cin.fail()
- Reading in from System.in – Java
- Checking cin input stream produces an integer
- Reading getline from cin into a stringstream (C++)
- Reading from .txt file into two dimensional array in c++
- std::cin input with spaces?
- How do I flush the cin buffer?
- cin.ignore(numeric_limits
::max(), ‘\n’) - Using cin for char array
- istream and ostream problem – C++
- How to use redirection in C for file input
- Frontend Category Checkbox
- Input with pattern not working
- Sleep for milliseconds
- C++ Cout & Cin & System “Ambiguous” [closed]
- Floating point exception( core dump
- Passing Arrays to Function in C++
- How can I clear console
- How to go from fopen to fopen_s
- Are vectors passed to functions by value or by reference in C++
- How does the modulus operator work?
- Single class has a Class Redefinition Error
- Identifier not found error on function call
- Debug assertion failed. C++ vector subscript out of range
- What causes a SIGABRT fault?
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- Socket Programming in C++
- How to prompt for user input and read command-line arguments
- What does the assignment of ~0u to a variable mean in C++?
- expected expression in C++?
- What does CreateFile(“CONIN$” ..) do?
- How to access the contents of a vector from a pointer to the vector in C++?
- printf with std::string?
- “Error: expression must have a pointer type” when using the “this” keyword
- Check jdk/JRE is installed and get path for jvm.dll
- C++ #include guards
- glm rotate usage in Opengl
- How can I iterate through a string and also know the index (current position)?
- c++ parse int from string [duplicate]
- C++ array assign error: invalid array assignment
- Is there a median function in the C++ library?
- Determine if map contains a value for a key?
- error: member access into incomplete type : forward declaration of
- Debug assertion failed
- “Implicit instantiation of undefined template” when forward declaring template class
- “…redeclared as different kind of symbol”?
- expected identifier before string constant
- C++ error: expected identifier before “(” token
- Function for C++ struct
- C++ error: double free or corruption (fasttop)
- no match for ‘operator<<’ in ‘std::operator
- android,
android-layout,
android-linearlayout,
gradient, - Reading multiple lines from a file using getline()
- Is there a standard C++ grammar?
- invalid use of non-static data member
- C: using strtol endptr is never NULL, cannot check if value is integer only?
- Using C-string gives Warning: “Address of stack memory associated with local variable returned”
- Don’t understand static boolean behavior
- How to write std::string to file?
- Member declaration not found
- What is the difference between a .cpp file and a .h file?
- Stable Cotangent
- How to change string into QString?
- Including .cpp files
- Class template inheritance C++
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- Initializing default values in a struct
- Warning: comparison of distinct pointer types
- Two decimal places using printf( )
- error C2244 unable to match function definition to an existing declaration
- Initializing pointers in C++
- Static vs dynamic type checking in C++
- stack around the variable…was corrupted
- Creating a list to hold objects in C++
- What does “warning: not all control paths return a value” mean? (C++)
- Array of Linked Lists C++
- Is it still safe to delete nullptr in c++0x?
- Declaration is incompatible with type
- One or more multiply defined symbols found
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- Get user id from email?
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- How to call or add password input / generate password / password strenght meter in custom registration form?
- Passing input value into name of input
- Hide input field when second input field is in focus
- Is there a way to add a custom input field for every taxonomy term in WP post editor?