![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#11
|
|||
|
|||
Re: In method `void InfixExpression::brCalc(double **, char **, int, int, int, int)'Quote:
You have, again made a lot of work for yourself by implementing hundreds of lines of code without testing whether your basic organization is consistent. See Footnote. Here's the typical organization for a simple program: 1. File InfixExpression.h has the class definition. If you want to put some of the implementations (the functions themselves) inside this file, then do it. Typically some small function implementations may be in here, but lots of people put just the data declarations and the function headers here. Any function declarations Inside the class definition don't need (and, in fact can't have) the InfixExpression:: part of the function declarations. I'll just show constructors and destructor that you wrote inside the class definition. CPP / C++ / C Code:
2. Now, in InfixExpression.cpp, you put all of the functions that weren't implemented in InfixExpression.h. Do not (that's not) declare the class again in InfixExpression.cpp. You will #include "InfixExpression.h", and the class is defined there. In this file, the function definitions will have the InfixExpression:: part. All of them will have it. CPP / C++ / C Code:
3. All files that have instances of the class and its members will #include "InfexExpression.h" Now, you might still have some problems with compiling the individual cpp files or in linking them all together (and maybe even some problems with functionality), but that's the way that most people would organize it, and is as a good a way as any. Next-to-Bottom line: you defined a function class in InfixExpression.h and included InfixExpression.h in your main.cpp, There was a class definition, whose member functions were prototyped but not implemented. The object file, main.o, had no way of filling in the function definitions. Here's why: The fact that your InfixExpression.cpp defined its own version of that class didn't help at all, since the class definition in main.cpp would hide the class with the same name that was defined somewhere else. Bottom line: See Footnote. Regards, Dave Footnote: Why, oh why, would you write hundreds of lines of code that involves something that you had never done before (and don't understand)? Why not just write a few lines (maybe give the class one function). Write, compile, test and debug the simple case (a few tens of lines at most). Then get to the new stuff. Questions could be shorter and simpler; answers could be shorter and simpler. Just a thought. |
|||
|
#12
|
|||
|
|||
reply to FootnoteThis exercise is my first exercise in c++.I took a course for c programing last semester and now I learn c++ in another course. Unfortunately, the home exercises on those two courses are very hard,especially because I do not have enough experience and yet I have no other choice but to do everthing in order to do them. I agree with you that it is stupid to give us so hard exercises from the very begining but I'm not the one who wrote the assignment.
By the way this is just half of the exercise. And again thank you for your help. |
|
#13
|
|||
|
|||
Re: reply to FootnoteQuote:
Quote:
1. To the best of my knowledge, I have never used the word "stupid" in any of my posts except when referring to my own stupidity. (Or maybe in my sometimes-feeble attempts to introduce a little humor. See Footnote.) Certainly not when talking about instructors. (Maybe some are stupid; maybe some of them do things that I consider stupid; I have never called those things stupid. Misguided maybe, in my opinion, but not necessarily stupid.) So: please don't put words in my mouth. 2. Maybe one of the things you are supposed to learn (even if your professor didn't say it---even if he/she doesn't know it) is that starting with a very simple and short program and building it incrementally might be a Good Way to do things. Test each step before going to the next. Then you might not have to retype so many of the things that you put in the program. Quote:
Hang in there... Regards, Dave Footnote: "Men are born ignorant, not stupid. They are made stupid by education." ---Bertrand Russell |
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 10:13 |
| Text-Based Roulette Game | mfm1983 | C++ Forum | 5 | 29-Nov-2006 12:20 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 03:48 |
| Pipeline freeze simulation | darklightred | C++ Forum | 6 | 27-Jul-2006 19:37 |
| creating a file in [c] | i hate c | C Programming Language | 15 | 21-Nov-2005 12:52 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The