具有不同参数的继承类构造函数的术语是什么
What is the term for an inheriting class constructor with different parameters?
以下面的示例为例。 你用什么术语来描述具有不同参数的继承类,然后是基类? 我知道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;
}
超载了我的朋友。它具有相同的方法名称,但不同的参数或返回类型
但在这种情况下,您只是在创建全新的构造函数。不是真正的继承或任何东西。
重载:更改派生类中继承函数的签名时。
重定义(如果是普通函数)/覆盖(如果是虚函数):当您在派生类中保持基类函数的签名相同时。但是您更改了实现部分。
但我在这里不是在谈论构造函数。我说的是类的常用成员函数。
相关文章:
- "error: no matching function for call to"构造函数错误
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- 选择要调用的构造函数
- 如何委托派生类使用其父构造函数?
- 构造函数正在调用一个使用当前类类型的函数
- 没有用于初始化C++中的变量模板的匹配构造函数
- 初始化具有非默认构造函数的std::数组项的更好方法
- 当从函数参数中的临时值调用复制构造函数时
- 在c++构造函数中使用随机字符串生成器
- 一对向量构造函数:初始值设定项列表与显式构造
- 从构造函数抛出异常时如何克服内存泄漏
- 我不明白为什么我声明一个空的内部结构并将其传递给构造函数
- 继承:构造函数,初始化C++11中基类的类C数组成员
- 具有默认模板类型的默认构造函数的类型推导
- 使用dynamic_cast和构造函数时出错
- 具有不同参数的继承类构造函数的术语是什么
- 构造函数的使用术语是什么