![]() |
|
#41
|
|||
|
|||
|
Quote:
dummy it up? do you think you know what's wrong with my menu? it'll be nice if at least my code would open the menu... but i havent been able to see my program 'cause its errors and errors... |
|||
|
#42
|
|||
|
|||
|
Quote:
CPP / C++ / C Code:
Quote:
|
|
#43
|
||||
|
||||
|
marita,
It seems that perhaps I missed the boat with some of my explanations to you. Good thing Dave picked up the slack. I do want to add that you have been making good progress, keep at it. From wayyyyy back at your first post: Quote:
So you have your list of requirements
That is your blueprint for your program. Don't get caught up in trying to complete everything at once. Take each step one at a time until you have them all done. First off though, you need to really read your errors. They seem for the most part to point directly to the offending lines. You have a few choices. My method is to comment out all the extra problems and get a compiled version (even if it doesn't do much to start) and slowly (like one at a time) add back in the pieces. To start with, your operator overloading is not going like you want. Do you really understand what you are trying to do with each. When you overload an operator it is so you can define how your program handles things like indexing ( the [] operator ) and assignment (the = operator). Quite frankly, you are jumping back and forth changing and adding but never having had anything to work with. Right now your class looks like this: Quote:
Quote:
As you can see, there are some changes based on the type of data (changing areacode and phone to ints) and some that may be a problem. Look at the operator[]. It is supposed to take a constant reference to a Phonebook object. Since your class name is now PhoneBook change references to Phonebook to match that (PhoneBook). Now the operator[] takes one argument, which is a reference to a constant object of type PhoneBook. The body of your function will handle some change to the normally defined operator. In your case this refers to item number 5 in the above list. Way down there. So I suggest just some basic changes to your class to get rid of the errors and work on your main a bit before tackling some of the more complicated parts. You can do this in a number of ways. For your example you can define everything (remembering the const PhoneBook&) and leave the body empty or comment out the actual code until you are ready to work on it. CPP / C++ / C Code:
Note the empty braces. This will require you to comment out your implementations (as they implement an empty method in the class definition) until you are ready to add them. As has been pointed out by both Dave and I, do these a little bit at a time from something that compiles. Here is a cut-away version of your code just so you can compile it. Then (and only then) you can add (one at a time) the parts of the program that make it actually do something. CPP / C++ / C Code:
CPP / C++ / C Code:
If you can do that part and get something you can run I can help you with the rest. You have actually been pretty close a number of times but then made drastic changes and ended up with some of your original errors again. One thing you really need to pay attention to is the include and using portions. If you want to use a function or variable it either has to be defined in your source code, or defined in code that you include. If you include something you than have to using it. This code of yours that I just posted is ready to dynamically allocate an array of PhoneBook objects for your project. That is your first item on the list and should be the first thing you implement. This will be done by creating an array of pointers for your PhoneBook type using new. They will have to be destroyed using delete. I do admire the fact that you have stuck with this. It is not simple what you are trying to do but it is not terribly difficult either. Somewhere in the middle (or a double blue if you are a skiier). If you really understand all this when you are done your future coding will be the better for it. Note the slight changes I have made. Read over the replies by Dave as they do a good job of expaining some concepts. Mark Here is the output from running the above: Code:
__________________
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs Stories from the NICU Blog |
|
#44
|
|||
|
|||
|
Hi!
Thank you very much for all your help! I really appreciate it. Sadly, i read this code TODAY! But anyways, i already sent my code to the professor, and i had a pretty nice grade, having in mind that my code did not compile. Anyways, now i have to make, mostly the same program but using a friend function. Im still working on it, but if i get stuck; i'll scream at ya! Thanks a lot! |
|
#45
|
|||
|
|||
|
Ermm.....
is there a way that i can write this line doing the same but WITHOUT using sizeof and getline? : CPP / C++ / C Code:
|
|
#46
|
|||
|
|||
|
This is the code i have right now:
CPP / C++ / C Code:
i need to have a friend function. That program is supposed to open the file phonebook.txt. Load ll that i have on the file into a class. The menu is supposed to search either by Name or by last Namr. A class is supposed to search in the file and what it has, save it on a new friend class and prints it into a new file. Having in mind that if the user enters one name (i.e. George and the file has more than one George, it is supposed to prints them all) Im kinda stcuk on what i have so far.... Some help please....? |
|
#47
|
||||
|
||||
|
I must have dropped this thread somewhere along the way. I didn't realize you were back at it.
If you are still interested:
Using g++ 3.4.1 with CygWin I get a number of warnings and errors. Code:
The line it refers to: CPP / C++ / C Code:
Code:
Code:
Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
Code:
Code:
Once you get to there you should have something like: Code:
These are all easy to fix if you look hard at it. I leave that to you. Try and fiqure out what you want to do with these lines: CPP / C++ / C Code:
Those are not correct. In fact, to show where their real problem lies I commented out the conditional statement and replaced it with a 0 so it would always fail. Because of the way they are written it creates an interesting problem. CPP / C++ / C Code:
Code:
Mark __________________
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs Stories from the NICU Blog |
Recent GIDBlog
Compress Your Web Site by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The