What is the difference between a "has a" and "is a" relationship?? I can't seem to find it in my book or by searching!
What is the difference between a "has a" and "is a" relationship?? I can't seem to find it in my book or by searching!
What are you taking a test? You know it's ok to group these questions into one post... infact... it's a whole lot better to do so.Originally Posted by carebear
A "Has a" relationship deals with object data members in classes. For instanceIn this example. myClassB "has a" myClassA object.Code:class myClassA; class myClassB { public: myClassA getA() { return myAObj; } private: myClassA myAObj; };
An "is a" relationship deals with inheritance.In this example, myClassB "is a" myClassA obj as well as a myClassB object.Code:class myClassA; class myClassB : public myClassA {};
Sent from my iPadŽ
Ah, we explained this in the earlier thread, kinda...
I think a "has a" relationship between classes is when class A contains a class member B. For instance every Person has a Pet.An is a relationship deals with inheritance; it's when Class B derives from class A.Code:class Person { private: Pet my_pet; };You see? A Bus is a Vehicle. It works like that.Code:class Vehicle { }; class Bus : public Vehicle { };
Last edited by whiteflags; 05-03-2006 at 01:02 AM.
The classes:
class Car;
class Wheel;
class Convertible;
Question 1: should Convertible be derived from the class Car? "Is a" Convertible a Car, i.e. is Convertible going to share the same properties and functions as Car with some extra stuff?
Question 2: should Wheel be derived from Car? "Is a" Wheel a Car? Nope. So, the functionality of a Car probably won't apply to a Wheel. However, a Car "has a" wheel. So, that would indicate aggregation would be appropriate, i.e. the Car class could have a member which is a Wheel object.
Oh, I figured I should address each thing seperately, I'll keep that in mind if I have a few questions to ask at once again. This is the last one I'm stumped on though lol. And yeah, I have searched my little heart out on just a few things and figured I'd just ask for some help on the ones that had me stumped.
Thanks so much, you guys have been so helpful! I was starting to seriously stress on not being able to figure out these last few questions lol. Again, I really appreciate it
Hmmm...sounds like someone is cheating.What are you taking a test? You know it's ok to group these questions into one post.
Heh, nah... it's like 2 AM in Missouri. I don't think carebear is testing right now.Originally Posted by 7stud
If anything, they're studying, or they're answering a handout... in the latter case, it's pretty cheap, but too innocent for me to call cheating.
Sent from my iPadŽ
Ever hear of a take home test? Graded homework assignment?
Not in college.
Not in my courses, anyway. Duly noted, though.
EDIT: Graded homework assignments are poo. It's open book, open notes... personally I think a person that doesn't research themselves deserves a slap on the wrists, but if their interest in the subject is so shallow that they don't care to pay attention or take notes, then I don't think they deserve their GPA rocked if they end up switching majors to something they like better.
It's not like they'll get to the top of the Programming career ladder on the backs of people who keep telling them the answers.
Last edited by SlyMaelstrom; 05-03-2006 at 01:16 AM.
Sent from my iPadŽ
Even if that is the case, we are not the moral police, and we certainly won't save his grade by answering questions on general theory. Plus we're not so mean as to be like! "SMELLS LIKE HOMEWORK! B&!" Not that I have anything against you.
..Trying to be funny mostly. It's late here.
Last edited by whiteflags; 05-03-2006 at 01:15 AM. Reason: HOEWORK: best typo ever