C++ calling base class constructors

后端 未结 6 1886
无人及你
无人及你 2020-12-08 00:23
#include 
#include  
using namespace std;

// Base class
class Shape 
{
   public:
      void setWidth(int w)
      {
         width =         


        
6条回答
  •  执笔经年
    2020-12-08 01:20

    The default class constructor is called unless you explicitly call another constructor in the derived class. the language specifies this.

    Rectangle(int h,int w):
       Shape(h,w)
      {...}
    

    Will call the other base class constructor.

提交回复
热议问题