No unique final overrider with virtual base class

Hi. I'm having some trouble doing an exercise from a book. I'll paste the classes specification:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 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?
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.
Thanks!
Topic archived. No new replies allowed.