Category : memory-management

This is a simple function which will take value from user and if value is invalid then the function will call itself recursively until a valid input is provided. #include<iostream> using namespace std; void getnum(){ int num; string strnum; getline(cin, strnum); try{ num = stoi(strnum); } catch(invalid_argument &ia){ cout<<"Invalid argumentn"; getnum(); } cout<<"n"<<num; } int ..

Read more

So I keep getting the same error when trying to delete pointers after I’ve used the new operator. I’ve checked online for ages and can’t wrap my head around whats going on, I’m very new to C++ and am working on a university assignment. Additionally I’ve successfully used new and delete operators for integer arrays ..

Read more