具有不同参数的继承类构造函数的术语是什么

What is the term for an inheriting class constructor with different parameters?

本文关键字:构造函数 术语 是什么 继承 参数      更新时间:2023-10-16

以下面的示例为例。 你用什么术语来描述具有不同参数的继承类,然后是基类? 我知道subbase是在隐含地称呼base(). 您不会将其称为重写,对吗,因为仍然调用基构造函数?

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
class base
{
public:
   base()
   {
      cout << "Hello!n";
   }
};
class subbase : public base
{
public:
   subbase(string s)
   {
      cout << s << endl;
   }
};
int main()
{
   subbase test("Hello World!n");
   return 0;
}

超载了我的朋友。它具有相同的方法名称,但不同的参数或返回类型

但在这种情况下,您只是在创建全新的构造函数。不是真正的继承或任何东西。

重载:更改派生类中继承函数的签名时。

重定义(如果是普通函数)/覆盖(如果是虚函数):当您在派生类中保持基类函数的签名相同时。但是您更改了实现部分。

但我在这里不是在谈论构造函数。我说的是类的常用成员函数。