当前位置: 首页 > article >正文

8.29 C++

作业

#ifndef CLASS_H
#define CLASS_H
#include <iostream>
using namespace std;
class Rect
{
private:
    int width;
    int height;
public:
    void init(int w,int h);
    void set_w(int w);
    void set_h(int h);
    void show();
};
#endif // CLASS_H

#include "class.h"

void Rect::init(int w, int h)
{
    width=w;
    height=h;
}

void Rect::set_w(int w)
{
    width=w;
}

void Rect::set_h(int h)
{
    height=h;
}

void Rect::show()
{
    cout << "area=" <<width*height <<endl;
    cout << "perimeter=" <<width*2+height*2 <<endl;

}

#include "class.h"
int main()
{
    Rect re;
    re.init(2,4);
    re.show();
    re.set_w(4);
    re.show();
    re.set_h(5);
    re.show();

    return 0;
}


http://www.kler.cn/news/289073.html

相关文章:

  • 常用Pandas操作(笔记整理)
  • 前端学习笔记-Web APIs篇-02
  • 基于机器学习的工业制造缺陷分析预测系统
  • 运动多线激光三维重建
  • 解决bug: RuntimeError: Address already in use,一个linux下pytorch多卡训练tcp端口占用的bug
  • SpringCloudGateway网关技术
  • 笔记整理—uboot番外(2)find_cmd函数
  • Selenium+Python自动化测试环境搭建
  • SAP自动化操作
  • L1-084 拯救外星人
  • Python 数据分析— Pandas 基本操作(上)
  • SprinBoot+Vue健康管管理微信小程序的设计与实现
  • 代码随想录训练营day51|图论part2
  • 解锁.NET安全奥秘:敏感数据加密与哈希的深度揭秘
  • C++系列-const所有用法总结
  • HALCON 错误代码 #7709
  • python-简单的dos攻击
  • 第十四章 rust集合库介绍
  • Mybatis【分页插件,缓存,一级缓存,二级缓存,常见缓存面试题】
  • 【HarmonyOS】模仿个人中心头像图片,调用系统相机拍照,从系统相册选择图片和圆形裁剪显示 (二)
  • 免费升级https访问
  • Vue3 reactive和ref
  • Chapter 07 watch侦听器
  • 【Next】1. 初识服务端渲染
  • OpenHarmony如何切换横竖屏?
  • 科研绘图系列:R语言富集火山图和通路图(volcano plot pathway)
  • 实现流程化办公,可专注于开源可视化报表设计器!
  • F12抓包01:启动、面板功能介绍、语言设置、前端样式调试
  • 【#第三期实战营闯关作业 ## MindSearch在 Hugging FaceSpace的部署】
  • 缓存解决方案。Redis 和 Amazon ElastiCache 比较