template <typename Z> Z myTemplate <Z> :: popFromVector ()
{
if (myVector.empty () == false)
return myVector.pop_back ();
return 0;
}
int main ()
{
myTemplate <int> obj;
std :: cout << obj.popFromVector();
return 0;
}
Error:
error: void value not ignored as it ought to be
AFAI can see, the return type of popFromVector
is NOT void. What's the point that I am missing?
The error disappears when I comment out this call in main().
std::vector<>::pop_back
is howevervoid
. You want something like{Z x=myVector.back(); myVector.pop_back(); return x; }
instead. – user786653myVector
? What is the line with error? – Maciej Piechotka