Per la mia class compsci, sto implementando una class template Stack, ma ho riscontrato un errore strano:
Stack.h: nella funzione membro ‘
const T Stack::top() const
[con T = int]’:Stack.cpp: 10: errore: passare ‘
const Stack
‘ come ‘this
‘ argomento di ‘void Stack::checkElements()
[con T = int]’ elimina i qualificatori
Stack::top()
aspetto:
const T top() const { checkElements(); return (const T)(first_->data); }
Stack::checkElements()
aspetto:
void checkElements() { if (first_==NULL || size_==0) throw range_error("There are no elements in the stack."); }
Lo stack utilizza nodes collegati per l’archiviazione, quindi first_
è un puntatore al primo nodo.
Perché ricevo questo errore?