Ok, this is my code for my function:
This, of course, is not what I want to do. I want to create a brand new variable and return it. Every time I do this, however, g++ gives an error (probably because the created variable falls out of scope)
BTW - Any variable with an 'm' as the fist character is a member variable.
Any help would be greatly appreciated :)
Code:
// Puke - new pointers only point to mTemp
Object &Coordinate::stripObject(std::string name) {
for ( int i=0; i < mItems.size(); i++ ) {
if ( mItems.at(i)->getName() == name ) {
mTemp = *mItems.at(i);
mItems.erase(mItems.begin() + i);
return mTemp;
}
}
Object item("Nothing");
mTemp = item;
return mTemp;
}
BTW - Any variable with an 'm' as the fist character is a member variable.
Any help would be greatly appreciated :)
Comment