Category : private

In the code below the public method Base2::f() is expected to become a private member of the Derived class however the compiler complains about ambiguity. The question is on the basic understanding of inheritance. I appreciate if someone can help to shed some light on it. #include <iostream> template <typename TDerived> class Base1 { public: ..

Read more

I’m working on a C++ project and I encountered this weird behavior. I have a Weapon class defined as follows: class Weapon { public: Weapon(std::string type); Weapon(void); ~Weapon(void); void setType(std::string type); std::string const &getType(void) const; private: std::string _type; }; And this human class: class HumanA { public: HumanA(std::string name, Weapon &Wp); ~HumanA(void); void attack(void) const; ..

Read more