Advertisement
Out of ideas…
Hello. I’ve been working on a program for a class (and using a class at that) that translates prefix to postfix using a LinkedList stack. We are supposed to create a stack class & use it to perform the task. My solution is not eloquent, but I can’t even find out IF it will work because it won’t compile, even after many rounds of “The power of Christ compiles you!” *sigh*
I’m using .NET environment for first time (it really isn’t winning me over) & wondering if its related? I get this error message:
“error C2227: left of '->TopFlag' must point to class/struct/union” paired with “error C2819: type 'stackType' does not have an overloaded member 'operator ->'” for each line where I referece my class object (mystack). It seems clear it isn’t recognizing my class object, but I don’t know why – i.e. error in declaration, error with linking.
The class files compile fine, but when I try to compile whole project it crashes. The instructor has looked at it & says “I ‘dunno” *grrr* it’s a small program.
Any chance someone out there would take a look at it & see if something jumps out? I can email text or .cpp files. Thanks a ton,
Rihanha
Hello. I’ve been working on a program for a class (and using a class at that) that translates prefix to postfix using a LinkedList stack. We are supposed to create a stack class & use it to perform the task. My solution is not eloquent, but I can’t even find out IF it will work because it won’t compile, even after many rounds of “The power of Christ compiles you!” *sigh*
I’m using .NET environment for first time (it really isn’t winning me over) & wondering if its related? I get this error message:
“error C2227: left of '->TopFlag' must point to class/struct/union” paired with “error C2819: type 'stackType' does not have an overloaded member 'operator ->'” for each line where I referece my class object (mystack). It seems clear it isn’t recognizing my class object, but I don’t know why – i.e. error in declaration, error with linking.
The class files compile fine, but when I try to compile whole project it crashes. The instructor has looked at it & says “I ‘dunno” *grrr* it’s a small program.
Any chance someone out there would take a look at it & see if something jumps out? I can email text or .cpp files. Thanks a ton,
Rihanha
Advertisement
Advertisement
-
Re: kind soul to help w/ homework?
Thu, May 5, 2005 - 5:18 PMIf you have an expression FOO->BAR then FOO must be one of two things. It must be a pointer to a class, structure or union type, or it must be an object that provides a custom -> operator.
The designers of C decided to have different member selection operators for accessing an object directly or through a pointer, and C++ retains that design decision. If FOO is a struct, class or union object, then FOO.BAR accesses member BAR. If FOO is a pointer to such an object then you use FOO->BAR.
A common programming mistake is to use the wrong one: to apply a . to a pointer, or -> to a non-pointer.
Maybe that is what is wrong in your program: that you want to be using the . operator instead of the -> operator. -
-
Re: kind soul to help w/ homework?
Thu, May 5, 2005 - 6:03 PMWhat he said. Sometimes it can be very hard to spot.
Sounds like you haven't found exactly what the compiler is griping about. If it's a complex expression break it into multiple lines by placing each part of the expression in a local or use parens &(expression) instead of &expression. Also some explicit casts may point out what the compiler is thinking.
-