子类构造函数参数列表,子类向父类传参数
来源:互联网 发布:linux怎么使用eclipse 编辑:程序博客网 时间:2024/06/10 21:12
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <conio.h>
using namespace std;
class animal
{
public:
animal(int height, int weight)
{
cout << "animal construct" << endl;
}
};
class fish :public animal
{
public:
fish(int _a) :animal(400, 300), a(_a)
{
cout << "fish construct" << endl;
}
private:
int a;
};
int main()
{
fish fh(2);
getchar();
return 0;
}
执行结果:
0 0
- 子类构造函数参数列表,子类向父类传参数
- C++类构造函数初始化列表,子类向父类传参数
- C++类构造函数初始化列表,子类向父类传参数
- 子类传递参数到多个基类构造函数
- 如何在子类中向父类的构造函数传递参数
- c++ 在子类中向父类的构造函数传递参数的小例子.包括类中常量的初始化
- [C++基础]在子类中向父类的构造函数传递参数的小例子,包括类中常量的初始化
- C++ 子类构造函数
- 子类构造函数
- 子类的构造函数
- 在子类中调用父类的带参数的构造函数
- 子类传递参数给它的父类的构造函数
- 在子类中调用父类的带参数的构造函数
- 在子类中调用父类的带参数的构造函数
- 子类中的this()(执行子类中参数对应的构造方法)
- 构造函数 参数初始化列表
- 子类构造函数与super()
- [C++]子类的构造函数
- UIDatePicker
- 2017-02-10 可靠数据传输原理简介
- 构建自动化前端样式回归测试——BackstopJS篇
- c++版 宽窄字符 转换方法
- hiberate 学习笔记
- 子类构造函数参数列表,子类向父类传参数
- selenium + python的环境安装
- Java实现文件拷贝(字节流)
- 1012. The Best Rank (25) PAT甲级
- 764D Timofey and rectangles[思维][染色]
- 萌新试玩python的踩坑史
- qsort与sort结构体排序
- 506. Relative Ranks | 分数排名
- 单例模式(饿汉模式、懒汉模式)