Let's say I have a class as
template <class T>
class c_array {
private:
T* m_arr;
int m_length = 0;
public:
T pop() {
if (m_length==0) {
//???
}
m_length--;
return m_arr[m_length];
}
};
What should I return if length==0?
Returning NULL gives a warning:
"warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]"
Trying
std::vector<int> vect;
int b = vect.pop_back();
Gives the error "error: void value not ignored as it ought to be"