Just having a small problem with something i'm playing around with.
Basically, I have two classes, an Orc class that creates Orc objects, and a Weapon class that creates Weapon objects. Both of these are fairly simple, i'm just trying to get comfortable with OOP in C++.
I have Orc.cpp, Weapon.cpp and the corresponding header files for both.
I also have a driver that creates Orc objects.
What i'm having trouble with is creating Weapon objects that are attributes of Orc objects.
That is, an Orc object has:
And in the Orc constructor, I try this:
I get "no match for call to (weapon)()" compiler error.
this->name = "";
this->hp = 100;
What am I doing wrong?
Also, a second question, how can I refer to the public functions within the weapon object from the orc object?
So basically, let's assume I have an Orc object called orc1, which inside it has the Weapon object weapon1 as a private attribute, how would I call a function of the weapon1? In java, it would look something like: