Sorry guys!My bad…I should have posted my main function though.
I was implementing a reverse polish notation calculator then I encountered this error which I could not figure any sort of clue out….
#include <iostream>
#include <string>
using namespace std;
class Exp {
protected:
string exp;
int value;
public:
Exp();
~Exp();
void setString(string s);//store conventional notation expression
void setValue(int n);//store the corresponding value of the expression
string getExp();//retrieve conventional notation expression
int evaluate();//retrieve the corresponding value of the expression
};
class unary : public Exp {
public:
void unaryyy(Expression *x,string op);
};
void unary::unaryyy(Expression *x,string op){
if(op=="ABS"){
if(x->evaluate() > 0) setValue(x->evaluate());
else setValue(-x->evaluate());
string l="| ";
l.append(x->getExp());
l.append(" |");
setString(l);
}
else if(op=="NEG"){
setValue(-x->evaluate());
string m="- ";
m.append(x->getExp());
setString(m);
}
}
...
int main(){
...
if(s=="ABS" || s=="NEG"){
unary *a = new unary;
a.unaryy(stack[p+1],s);
stack[p+1]=a;
...
}
Then,when debugging,the complier gave me a heads up that in main function,my ‘unaryy’ function has not been declared.
should be
->should be used calling methods with pointers