473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Infix to Postfix Conversion Header File

Alright basically I just have one simple question. I can code perfectly fine and don't have any problems with the .cpp of the infix class but with my header I can't get anything to work really, any guideline as to how to start this would be great. It has to work with assign.cpp which is like this:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.  
  4.    Infix infix;
  5.  
  6.    while (true)
  7.    {
  8.       //cout << "Enter an infix expression like 2*(3+4): " << endl;
  9.  
  10.       infix.read();
  11.  
  12.       if (cin.eof() )
  13.      break;
  14.  
  15.       infix.write();
  16.       cout << " = " << infix.evaluate() << endl;
  17.  
  18.    }  // end while
  19.  
  20.    return 0;
  21. }  // end main
I know this is sorta a dumb question but it's the only problem I'm really having.
Thanks
Mar 21 '07 #1
5 3723
horace1
1,510 Expert 1GB
I assume if you include the infix.cpp file it works OK but when you try to just include the infix.h and link the infix.cpp at link time you have problems??
have you an example of the header that is causing problems? or a list of error messages?
Mar 21 '07 #2
Basically it is telling me with the infix.read() function types that the item to the left of .read() has to be a class, structure, etc. So basically it must have something to do with my constructor at the moment. Except the thing is I don't even know what to put in my constructor, I have a couple functions initiliazed outside of it but otherwise I have just a default constructor. Sorry I know this is really vague but I do NOT understand header files for some ridiculous reason. Any help or input would be great.

Thanks
Mar 21 '07 #3
horace1
1,510 Expert 1GB
Basically it is telling me with the infix.read() function types that the item to the left of .read() has to be a class, structure, etc. So basically it must have something to do with my constructor at the moment. Except the thing is I don't even know what to put in my constructor, I have a couple functions initiliazed outside of it but otherwise I have just a default constructor. Sorry I know this is really vague but I do NOT understand header files for some ridiculous reason. Any help or input would be great.

Thanks
think you are going to have to post some code
Mar 21 '07 #4
Here is my .h so far. As you can see I've just initialized the functions that I"m going to be using in the .cpp.
Expand|Select|Wrap|Line Numbers
  1. namespace Project4a {
  2.  
  3.  
  4.     public ref class Infix : public System::Windows::Forms::Form
  5.     {
  6.     public:
  7.         Infix(void)
  8.         {
  9.             InitializeComponent();            
  10.  
  11.         }
  12.         void initStack(STACK *stack);
  13.         void get_infix(char infix[]);
  14.         void convertToPostfix(char infix[], char postfix[]);
  15.         int isOperator(char c);
  16.         int precedence(char operator1, char operator2);
  17.         int pred_level(char ch);
  18.         void push(STACK *stack, char value);
  19.         char pop(STACK *stack);
  20.         char stackTop(STACK *stack);
  21.         int isEmpty(STACK *stack);
  22.         int isFull(STACK *stack);
  23.         void printResult(char infix[], char postfix[]);
  24.         void print_msg(void);
  25.  
  26.     protected:
  27.  
  28.         ~Infix()
  29.         {
  30.             if (components)
  31.             {
  32.                 delete components;
  33.             }
  34.         }
  35.  
  36.     private:
  37.  
  38.         System::ComponentModel::Container ^components;
  39.  
  40.  
  41.  
However the errors I"m getting are coming up in the assign.cpp which has the following code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. int main()
  3. {
  4.  
  5.    Infix infix;
  6.  
  7.    while (true)
  8.    {
  9.       //cout << "Enter an infix expression like 2*(3+4): " << endl;
  10.  
  11.       infix.read();
  12.  
  13.       if (cin.eof() )
  14.      break;
  15.  
  16.       infix.write();
  17.       cout << " = " << infix.evaluate() << endl;
  18.  
  19.    }  // end while
  20.  
  21.    return 0;
  22. }  // end main
My main question is just about what I need to do in order to get the header file to make it so that the rest of the program recognizes it as an object of a class. Infix that is.

Thanks
Mar 21 '07 #5
Ganon11
3,652 Expert 2GB
Since the class is included inside a namespace, you may have to write

Expand|Select|Wrap|Line Numbers
  1. Project4a::Infix infix;
instead of

Expand|Select|Wrap|Line Numbers
  1. Infix infix;
or at the top of your main() program, put the statement

Expand|Select|Wrap|Line Numbers
  1. using namespace Project4a;
Mar 21 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: KidLogik | last post by:
Hello! I am converting an infix expression string into a postfix so that I will be able to evaluate it easier -> (5*(((9+8)*(4*6))+7)) == 598+46**7+* I believe the rule is "Replace all...
22
by: Tony Johansson | last post by:
Hello Experts! I'm reading i a book about C++ and they mention infix with telling what it is. I hope you out there can do so. Many thanks! //Tony
19
by: caramel | last post by:
i've been working on this program forever! now i'm stuck and going insane because i keep getting a syntax error msg and i just can't see what the compiler is signaling to! #include <stdio.h>...
11
by: Nhd | last post by:
Hi... I need a program to convert an infix arithmetic expression to postfix with the use of stacks... Can anyone tell me how do i go about implementing this? thanks
30
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”....
0
by: coolguyjas07 | last post by:
plzzzzzz help me out to run my source code ......... i hav written dis code to convert infix expression to postfix but not getting desired output.... plzzz help me to get correct output.. d source...
4
by: madhumitha29 | last post by:
Does anyone know a simple C program to covert an infix to a postfix expression?plz kindly help!
1
by: aitia | last post by:
this the code. i used ECLIPSE to run this.. it has some codes smells that i can't seem to figure out.. can any one help? import java.io.*; import java.util.*; public class Postfix { private...
2
by: zeroeight | last post by:
Hi guys, I'm a newbie here, I just want to seek for help regarding my program. I want to implement an infix to postfix conversion only accepting numbers. Right now, I already debugged the errors...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.