![]() |
|
#1
|
||||
|
||||
First time using classesJust wanted to run this past someone in the know. This is my first time designing/using classes in C++ and I wanted to make sure I sorta know what I'm doing before I go further. So, if someone would be kind enough to look at my code and let me know if I'm jacked up or not, that would be great.
I'm not sure about the changePosition() method. What I want to do is move a point from one location to another. (Just thought it would be a nice thing to have available.) I just don't know if what I have in mind is what I coded. I haven't completed the main program yet, just this header file, since I want to make sure I'm on the right path before I get lost. Thanks for the look. CPP / C++ / C Code:
__________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#2
|
||||
|
||||
|
seems all good to me
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#3
|
||||
|
||||
Error messages on compileI've finally completed all the code for this problem, but now I get the inevitable compile errors. The following are examples of the errors.
Code:
I think I'm being told that I'm trying to access objects and methods incorrectly, but I don't see how to fix it. Any help? My headers and source are attached in a zip file. Thanks. __________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#4
|
||||
|
||||
|
Hello crystalattice. Using g++ & Linux, I got a ton of errors, mostly related to my compiler. However, I did notice a few things:
First, in this sample you are calling functions, but you aren't using (). This: CPP / C++ / C Code:
Should be more like: CPP / C++ / C Code:
Also, why are you passing in a Line? I am missing something there, I think... Also, this is really confusing to me here: CPP / C++ / C Code:
pointSlope is a member function of Line, but it appears that you are trying to use it as a defined variable of a class? Also, I can not figure out where slope_line, point_y & point_x are defined local to Line. My use/understanding of classes are pretty basic and maybe you are trying to do something that is way over my head here, so I apologize if that is the case... __________________
The best damn Sports Blog period. |
|
#5
|
||||
|
||||
|
Oh, trust me, I'm not trying to do tricky things. If you don't understand it, then I probably "made it up" because I don't understand my textbook all that well.
I'll look again at what you found. I didn't even realize I'd missed the "()" on the end of the functions. Thanks. __________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#6
|
||||
|
||||
|
Quote:
Okay. When you work with classes, your member functions are meant to work on the member data that you have. Classes are not that much different from a structure except that you have member functions. So there is no need to pass member data to a member function CPP / C++ / C Code:
Also member functions should really be limited to working on member data only. If you have a function that finds where two lines intersect, this should be defined external as you will need to pass two seperate line classes into it. All in all, I don't think that you are too far off on this. You may just want to step back and re-evaluate your member functions. HTH. __________________
The best damn Sports Blog period. |
|
#7
|
||||
|
||||
|
Quote:
As this is true on most compilers, I just want to add that in case of MS VC, it works either way when creating a new instance of a class. CPP / C++ / C Code:
Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 15:13 |
| Re: Programming Techniques | WaltP | C Programming Language | 0 | 09-Mar-2004 23:56 |
| time Problem | zuzupus | MySQL / PHP Forum | 9 | 24-Jul-2003 07:02 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The