Class instance of another class instance?
· November 6, 2015
Okay, let's see if I have this right. If I decided to write an RPG, and I want to have class Player, and class Weapon... 2 classes
I can create an instance of Player that has the instance of weapon inside it? That sounds pretty cool.
But it does raise some questions...
1st, obviously how do you do this?
2nd Let's say I want to calculate damage from the weapon, how do I access it?
Do I have to go through Player :: Weapon.damage ??
Would I have to write a method in Player to access a method of weapon?
What are the advantages and dis - advantages of doing this?
Post a Reply
|Oldest Newest Rating|
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|