I have a problem with a certain part of code I'm currently working on.
I have a vector sorting a set of HObjects (self defined class).
I want to create a pointer to a HObject being popped from the vector.
However, (***) is giving me this error:
new = set.pop_back(); //***
"void value not ignored as it ought to be"
Is there something wrong with the way I'm doing this?
pop_back does not return a value for one, you have to get the values beforehand. Also, you are popping it so the object should be lost, the pointer would mean nothing. You should probably be storing a vector of pointers instead. Something like this:
try that out
fillvector(set); //puts dyn allocated instances in it
new = set[set.size()-1];
just realized, you used "new" as a variable name too. naughty naughty.
Yes, new is a reserved keyword. Your IDE should have changed its color for you. (Assuming you use that feature) As Hershlag said, you cannot use reserved keywords for variable names.