I have four classes (classic diamond problem in C++). Let's call the grandparent class A, the parent classes B and C and the child class D. Both B and C have a public member function called attack. I want D to use B's attack function. Class D looks like this:
class D : public B, public C
{
using B::attack;
public:
D(void);
D(std::string &name);
D(D &instance);
~D(void);
D& operator=(D &instance);
};
The attack function simply displays a message on the standard output. My main looks like this:
int main(void)
{
DiamondTrap dt;
dt.attack();
}
The error I get is the following:
error: 'attack' is a private member of 'D'
note: implicitly declared private here
using B::attack;
Does this mean that using using keyword makes member functions private? I don't know why attack is now private. I can call attack it in my main function from an instance of B, but not from an instance of D. I wish to call it from an instance of D. How can I solve this?
Note I don't know if this is relevant to my problem, but B and C's inheritance is virtual, so only one instance of A is created when an instance of D is created. Also, I am not allowed to use friend keyword in my solution, and I am only allowed to use C++98.