New user here. Actually, new programmer here! I'm taking a c++ course and I'm stuck on classes and objects. I've done a TON of research and read multiple textbooks and for some reason things aren't clicking for me. We are working on an assignment that, in a nutshell, creates a class that takes two variables (let's say length and width).
I've figured out how to do this using get and set functions. But then, we have to use math on these variables. We're supposed to write a function that takes one instance of the class as a parameter (so two variables), and then does math on both this object (the one taken as a parameter) and object that the method of was called.
Part of why I'm confused is the language, and I'm not sure exactly what that means. Sorry if it's not clear, I don't know how to really explain it because I don't know what it means!
So far, like I said, I managed to be able to end up with setLength and setWidth variables set via user input. I am really, really stuck on trying to then pass these values (or this object?) to a function and then call the method of another object?
I apologize if this is skeletal. I mentioned this is for class, so I'm trying to give as little and as vague information as possible because I'd really like to figure this out on my own. Maybe if someone could help me figure out what "taking an object as a parameter and then doing math on the object i called the method of" means? Or just help with passing objects? As I said, I have done a ton of research but nothing seems to be helping. I figure if I can engage in a dialogue and ask questions it will help me understand!
Thank you in advance :)
Aucun commentaire:
Enregistrer un commentaire