No Unique Final Overrider With Virtual B - C++ Forum

cplusplus.com
  • TUTORIALS
  • REFERENCE
  • ARTICLES
  • FORUM

C++

  • Tutorials
  • Reference
  • Articles
  • Forum

Forum

  • Beginners
  • Windows Programming
  • UNIX/Linux Programming
  • General C++ Programming
  • Lounge
  • Jobs
  • Forum
  • Beginners
  • No unique final overrider with virtual b

No unique final overrider with virtual base class

Kurospidey (14) Hi. I'm having some trouble doing an exercise from a book. I'll paste the classes specification:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 // persons.h -- Person and derived classes definition (for project Exercise 14.4.cbp) #ifndef PERSONS_H_ #define PERSONS_H_ #include <string> #include "card.h" //VIRTUAL BASE CLASS (it requires new syntax rules) class Person { private: std::string fname; std::string lname; protected: void Get(); // for inputting void Data() const; // for outputting public: Person(const std::string& f = "John", const std::string& l = "Doe"); // default constructor virtual ~Person() {} // it uses the automatic default copy constructor and assignment operator virtual void Show() const; // to take advantage of the * and & property virtual void Set(); }; class Gunslinger : public virtual Person { private: int notches; // number of nothces in a Gunslinger gun const double SXN; // seconds it takes to draw a Gunslinger per notch (initialized in the default constructor) protected: void Get(); void Data() const; public: Gunslinger(const int& nchs = 1, const std::string& f = "John", const std::string& l = "Doe"); // default constructor virtual ~Gunslinger() {} double Draw() const; // Gunslinger draw time virtual void Show() const; virtual void Set(); }; class PokerPlayer : public virtual Person { private: Card card; void RandCard(); // private method to generate a random card protected: void Get(); void Data() const; public: PokerPlayer() {} // default constructor PokerPlayer(const Card& c, const std::string& f = "John", const std::string& l = "Doe"); virtual ~PokerPlayer() {} Card& Draw(); // returns a Card object with random values (for suit and face) virtual void Show() const; virtual void Set(); }; class BadDude : public Gunslinger, public PokerPlayer { protected: void Data(); public: BadDude() {} // inline default constructor BadDude(const Card& c, const int& nchs = 1, const std::string& f = "John", const std::string& l = "Doe"); double Gdraw() const; Card Cdraw() const; void Show(); void Set(); }; #endif
The compiler sends the following error: no unique final overrider for 'virtual void Person::Show() const' in 'BadDude'. How can I solve this? vlad from moscow (6539) In base classes there is defined function void Show() const; However in the derived class you are declaring a new function void Show(); (without qualifier const) that hides the function with the same name in the base classes. Kurospidey (14) Thanks! Topic archived. No new replies allowed. Home page | Privacy policy© cplusplus.com, 2000-2026 - All rights reserved - v3.3.3Spotted an error? contact us

Tag » C++ No Unique Final Overrider For