I am Getting following errors I don't know why.I have mentioned the lines (in comments) where these errors are occurring.
__________________________________________________
warning C4018: '<' : signed/unsigned mismatch
error C2064: term does not evaluate to a function taking 0 arguments
error C2064: term does not evaluate to a function taking 0 arguments
__________________________________________________ _
Code:
/////////////////////////////////////////////////
//libraries
/////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
/////////////////////////////////////////////////
// General Stack
////////////////////////////////////////////////
template <class Type>
struct link{
Type data;
link<type>* next;
};
template <class Type>
class stack{
public:
int size;
link<Type>* top;
stack(){
size=0;
top = NULL;
}
void additem(Type d);
string pop();
int get_size(){return size;}
void push(string o);
void stack_upper();
bool stack_empty();
void display();
string top();
};
//////////////////////////////////////////////
//Stack Functions
/////////////////////////////////////////////
template<class Type>
void stack<Type>::additem(Type d){
link<Type>* newlink = new link<Type>;
newlink->data=d;
newlink->next=first;
first=newlink;
}
template<class Type>
void stack<Type>::display(){
link<Type>* current=first;
while(current!=NULL){
cout << current->data << endl;
current= current->next;
}
}
template<class Type>
string stack<Type>::top(){
return top;
}
template<class Type>
void stack<Type>::push(string ele)
{
link *temp;
temp =new link;
if(top==NULL){
temp->next =NULL;
}
else{
temp->next =top;
}
temp->data=ele;
top=temp;
size++;
}
template<class Type>
bool stack<Type>::stack_empty()
{
if(get_size()==0)
return true;
return false;
}
template<class Type>
string stack<Type>::pop()
{ string d;
if(stack_empty()){
cout<<"\nStack is Empty\n";
return ;
}
else{
link *temp = top;
top=top->next;
d=temp->data;
delete temp;
size--;
}
return d;
}
//////////////////////////////////
//Some Definitions
/////////////////////////////////
string infix; // infix exression string
string operand;
string operate;
stack <string> mystack; // this stack is used to push the operator
string postfix; // postfix string where the operand is appended
////////////////////////////////////////////////
/////Expression Evaluator Class
////////////////////////////////////////////////
class ee{
private:
public:
string convert();
bool isopp(char c);
int precedence(string e);
};
//////////////////////////////////////////////////
///Expression Evaluator Class Functions
/////////////////////////////////////////////////
int ee::precedence(string e)
{
int f;
if(e == "*" || e== "/" || e =="%")
f = 2;
else
{
if(e == "+" || e == "-")
f = 1;
}
if(e=="."){
f=0;
}
return f;
}
ee objee;
string ee::convert()
{
for(int i=0; i<infix.length(); i++)//warning C4018: '<' : signed/unsigned mismatch
{
switch(infix[i]){
// operate case start
case '+': case'-': case'*': case'/': case'^': case '(': case ')': case'.':
operate=infix[i];
{
if(mystack.stack_empty() || objee.precedence(operate)>= objee.precedence(mystack.top())) // error C2064: term does not evaluate to a function taking 0 arguments
{
mystack.push(operate);
break;
}
else
{
while(!mystack.stack_empty() && objee.precedence(operate)< objee.precedence(mystack.top())) // error C2064: term does not evaluate to a function taking 0 arguments
{
postfix.append(mystack.top());
mystack.pop();
}
mystack.push(operate);
}
}//operate case closed
default: //when operand string char is parsed
{
operand=infix[i];
postfix.append(operand);
break;
} // default case closed
}//switch closed
}// for loop close
while(!mystack.stack_empty())
{
postfix.append(mystack.top());
mystack.pop();
}
return postfix;
cout<<postfix;
} // function close braces
bool ee::isopp(char c){
if (c=='+' || c=='-' || c=='*' || c=='/' || c=='%' || c==')' || c=='(' || c=='^')
return true;
else
return false;
}
string input()
{
cout<<" Enter the damn infix expression: "<<endl;
getline(cin, infix);
return infix;
}
int main()
{
input();
objee.convert();
cout<<"postfix is "<<postfix<<endl;
}