C++中的简单继承
2024-10-01 08:51:25
Father.cpp:
#include<iostream>
using namespace std;
class Father
{
protected:
int width;
int height;
public:
void setWidth(int widths)
{
width = widths;
}
void setHeight(int heights)
{
height = heights;
}
}; class Son : public Father
{
private:
int weight;
public:
void setWeight(int weights)
{
weight = weights;
}
void show()
{
cout<<"width ="<<width<<"\t"<<"height="<<height<<"\t"<<"weight="<<weight<<endl;
}
}; int main()
{
Son a;
a.setWeight();
a.setHeight();
a.setWidth();
a.show();
return ;
}
运行结果:
最新文章
- 理解 Neutorn LBaaS - 每天5分钟玩转 OpenStack(120)
- linux 学习 13 系统管理
- 网络编程socket基本API详解(转)
- ABAP之DIALOG
- Java:静态导入
- JavaScript中bind、call、apply函数用法详解
- C++之sort函数
- selenium 多线程
- OPEN A PO ORDER OR SO ORDER
- spring security5.0源码导入idea
- Excel Foundation Install
- 闪付卡(QuickPass)隐私泄露原理
- POJ 3461 Oulipo(模式串在主串中出现次数 可重叠)
- taro 事件处理
- 2. springboot启动报错:Field userMapper in com.service.UserService required a bean of type &#39;com.dao.UserMapper&#39; that could not be found.
- <;Lord don’t move that mountain>;
- delphi程序中定义热键
- net core 发布到服务器的方式
- Charles下载和使用
- js 数据格式化
热门文章
- Write-Up-wakanda-1
- 学习之学习--混沌大学商学院--第一课--HHR计划
- CentOS修改各大yum源(centos5,centos6,centos7)
- 【快学Docker】Docker镜像相关操作
- Spring学习(三)
- Caffe2 的基本数据结构(Basics of Caffe2 - Workspaces, Operators, and Nets)[4]
- RESTFul Client入门实例
- uniapp - 导航切换(样式)
- 前后端分离后API交互如何保证数据安全性?
- error C4996: &#39;fopen&#39;: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation