Problem with infix to postfix

Could anyone help with my code. Im trying to do a program that infix to postfix
for an algebra equation. Also , im trying to get the Result from the equation.
My 1st question is this...
when i compile my code on VISUAL BASIC 2008 it says this...
int priority(char value);

int main()
{
ItemType<char> ArrayOne;
ItemType<char> Post;

char Array[MAXSIZE];
int i;
int sum=0;

cin >> Array;
ArrayOne.Push(' ');

int Lenght = strlen(Array);

for(i=0; i < Lenght ; i++)
{
if(Array[i] == '(')
{
ArrayOne.Push(Array[i]);
}

if((Array[i] == '+') || (Array[i] == '-')||
(Array[i] == '/') || (Array[i] == '*'))
{
while(priority(ArrayOne.Top()) >= priority(Array[i]))
{
cout << ArrayOne.Top();
Post.Push(ArrayOne.Top());

ArrayOne.Pop();
}

ArrayOne.Push(Array[i]);

}

if(Array[i] == ')')
{
while(ArrayOne.Top() != '(')
{
cout << ArrayOne.Top();
Post.Push(ArrayOne.Top());
ArrayOne.Pop();
}
ArrayOne.Pop();
}


if(isdigit(Array[i]))
{
cout << Array[i] ;
Post.Push(Array[i]);

}
}

while(!ArrayOne.IsEmpty())
{
if((ArrayOne.Top() == '+') || (ArrayOne.Top() == '-')||
(ArrayOne.Top() == '/') || (ArrayOne.Top() == '*'))
{
cout << ArrayOne.Top();
Post.Push(ArrayOne.Top());
}
ArrayOne.Pop();
}

cout << " = " ;
cout << endl;

//Ive got til here my postfix (Post) , and now im trying to create another dynamic Array to inverse that postfix so I can have the 1st digit on "Top" Example : infix: (2+1)/(9-6)
my Post : 21+96-/
so my Reverse Rev will be /-69+12 --> 2 on top... to use it for the result.

ItemType<char> Rev;

while(!Post.IsEmpty())
{
Rev.Push(Post.Top());
Post.Pop();
}

cout << Rev.Top()<< endl; // 2

//BUT WHEN I DO THIS ...

ItemType<int> Sum;
Sum.Push(Rev.Top());
Rev.Pop();

//.. TO START PASSING VALUES TO ANOTHER DYNAMIC ARRAY , SO I CAN START ADDITION ITS SAYS THIS ....

1: warning C4715: 'ItemType<char>::Top' : not all control paths return a value
: warning C4715: 'ItemType<int>::Top' : not all control paths return a value



return 0;
}

int priority(char value)
{
if((value == '+') || (value == '-'))
{
return 1;
}
else
{

if((value == '*') || (value == '/'))
{
return 2;
}
else
{
return 0;
}
}
}

HOW COME?!

This is my header...

template<class T>
class ItemType
{

public:

ItemType();

bool IsEmpty();

bool IsFull();

void Push(T item);

void Pop();

T Top();

~ItemType();

private:
int top;
T* Stack;

};

template<class T>
ItemType<T>::ItemType()
{
top = -1;
Stack = new T[MAXSIZE];
}

template<class T>
bool ItemType<T>::IsEmpty()
{
return (top == -1);
}

template<class T>
bool ItemType<T>::IsFull()
{
return (top == MAXSIZE-1);
}

template<class T>
void ItemType<T>::Push(T item)
{
if(IsFull())
{
cout << "Stack is full" << endl;
}
else
{
top++;
Stack[top] = item;
}
}

template<class T>
void ItemType<T>::Pop()
{
if(IsEmpty())
{
cout << "Stack is empty" << endl;
}
else
{
top--;

}
}

template<class T>
T ItemType<T>::Top()
{
if(IsEmpty())
{
}
else{
return Stack[top];
}
}

template<class T>
ItemType<T>::~ItemType()
{
delete [] Stack;
}


ANY IDEA?!
Topic archived. No new replies allowed.