Need Help Writing a Postfix calculator in C++

B

Blackjack2000

Compiling in Microsoft Visual C++ 6.0...

It has to use a dynamic ADT Stack

I wrote the ADT stack (something I'm not really good at yet) but I have not been able to figure out this error. It occurs when I make the function call:

answer = testStack.postFix(expression);

postFix is a member function that takes a string as a value parameter and returns an int. This is the error I get:

Compile Error

error C2440: '=' : cannot convert from 'int (__thiscall Stack::*)(int [])' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast


It looks like I'm trying to return data of the wrong type, but I went over the code, and I everything seemed to be right. I think it's probably some nuance of the ADT that I haven't figured out yet and will take a few more hours. The asterisk in the error statment makes me think it's a problem with pointers, in which case I have nothing but headaches to look forward to...

I'm too tired to try anything else tonight, but would it work if I changed it to a void function and used a reference parameter? Any help would be appreciated.
 

onelin

Senior member
Dec 11, 2001
874
0
0
last time I saw the convert thing, int[] and int means something's a pointer and something's not...both should be the same.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
Doesn't that error mean that you're trying to convert a function pointer into an int. Does postFix possibly return just the function pointer that is supposed to be evaluated rather than the results of the evaluation?
 
B

Blackjack2000

Thanks for the help, I'll have a look at it after I get back from class.