GyroVorbis wrote:Dude, that should be way more common than inheritance and friendship. Don't let whatever OO guide you're reading make you think differently.
What if the class1 is a player, and class2 is a weapon? The player has a weapon. What if class1 is a GUI, and class 2 is a button? The GUI has a button. What if class1 is a dude, and class2 is his penis? The dude has a penis.
You should have noticed the "has a" relationship. If you can ever say that class1 "has" class2, you don't use inheritance. That's how you handle the scenario.
So I would use something like this to sorta connect
the classes together:
class Character
{
public:
private:
Weapon weapon;
};
class Weapon
{
public:
private:
};
Man I must have confused Inheritance or something...
Inheritance is like extending a base class right?
How would I access an object of a class inside
the class? Is it the same as accessing a regular
private variable?
The book I read wasn't that good I mostly learned
all this stuff through sitting down and doing trial
and error with some googling and also asking
questions.
I went through 2 classes in college of c++ and basically
had to teach myself this language. The instructor wasn't
very good and was too slow paced in my opinion but anyways...