- #include
-
- using namespace std;
- class shape
- {
- protected:
- int c;
- int s;
- public:
- shape(){}
- shape(int c,int s):c(c),s(s)
- {
- cout<<"有参构造"<
- }
- ~shape()
- {
- cout<<"析构函数"<
- }
- void show()
- {
- cout<<"周长="<
" 面积="< - }
- };
- class circle:public shape
- {
- private:
- int ri;
- public:
- circle(){}
- circle(int r):ri(r)
- {
- c=2*3.14*ri;
- s=3.14*ri*ri;
- cout<<"有参构造"<
- }
- ~circle()
- {
- cout<<"析构函数"<
- }
- void display()
- {
- cout<<"circle::周长="<
" circle::面积="< - }
- };
- class rect:public circle
- {
- private:
- int len;
- int high;
- public:
- rect(){}
- rect(int l,int h):len(l),high(h)
- {
- c=2*(len+high);
- s=len*high;
- cout<<"有参构造"<
- }
- ~rect()
- {
- cout<<"析构函数"<
- }
- void display1()
- {
- cout<<"rect::周长="<
" rect::面积="< - }
- };
-
- int main()
- {
- shape s1(5,6);
- s1.show();
- circle s2(4);
- s2.display();
- rect s3(5,6);
- s3.display1();
- return 0;
- }

-
相关阅读:
gitee提交代码Commit和Push时窗口不小心关了,怎么继续推送提交?
Day2.
在 Windows 10 | Docker Desktop | Kubernetes 环境 使用 hostPath / local 为 POD 配置本机目录
JAVA Annotation 详解
详细介绍R语言在数据分析中的应用
DCM 中间件家族迎来新成员
vue实现文字手工动态打出效果
linux笔记(6):东山哪吒D1H显示HDMI测试-命令行调试
(阿里云)Linux部署SSM项目全过程
【Java8新特性】Optional类在处理空值判断场景的应用 回避空指针异常 编写健壮的应用程序
-
原文地址:https://blog.csdn.net/weixin_69452640/article/details/132838887
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU