📜  cpp 语言解释 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:54.814000             🧑  作者: Mango

代码示例1
#include 
using namespace std;
class BaseClass {
public:
   void disp(){
      cout<<"Function of Parent Class";
   }
};
class DerivedClass: public BaseClass{
public:
   void disp() {
      cout<<"Function of Child Class";
   }
};
int main() {
   /* Reference of base class pointing to
    * the object of child class.
    */
   BaseClass obj = DerivedClass(); 
   obj.disp();
   return 0;
}