#include<string>
#include<ctime>
class Person // an abstract base class
{
private:
std::string firstname;
std::string lastname;
protected:
virtual void Data();
virtual void Get();
public:
Person() : firstname("no firstname"), lastname("no lastname") {}
Person(const std::string& s1, const std::string& s2)
: firstname(s1), lastname(s2) {}
virtual ~Person() {} // pure virtual function
virtual void Show();
virtual void Set();
};
class Gunslinger :virtual public Person {
private:
double gun_time;
int nickings;
protected:
virtual void Data();
virtual void Get();
double Draw() { return gun_time; }
public:
Gunslinger() :Person(), gun_time(0.0), nickings(0) {}
Gunslinger(const std::string& s1, const std::string& s2, double gt, int n)
:Person(s1, s2), gun_time(gt), nickings(n) {}
Gunslinger(const Person& p, double gt, int n)
:Person(p), gun_time(gt), nickings(n) {}
~Gunslinger() {}
virtual void Show();
vir
虚基类继承时虚函数的重写问题?
最新推荐文章于 2022-10-29 19:25:39 发布