函数体=0的虚函数称为“纯虚函数”.包含纯虚函数的类称为“抽象类” #include <string> class Animal // This Animal is an abstract base class { protected: std::string m_name; public: Animal(std::string name) : m_name(name) { } std::string getName() { return m_name; } ; // note that sp…
Ordinarily, if we do not use a function, we do not need to supply a definition of the function. However, we must define every virtual function, regardless of whether it is used, bacuase compiler has no way to determine whether a virtual function is u…
An abstract function has to be overridden while a virtual function may be overridden. Virtual functions can have a default /generic implementation in the base class. An abstract function can have no functionality. You're basically saying, any child c…