技术栈

c++day2

魔法又鸟2023-10-12 14:26
cpp 复制代码
#include <iostream>

using namespace std;

class Rect
{
    int width;
    int height;
public:
    void init(int w,int h);
    void set_w(int w);
    void set_h(int h);
    void show();
};
void Rect::init(int w,int h)
{
    this->width = w;
    this->height = h;
}
void Rect::set_w(int w)
{
     this->width = w;
}
void Rect::set_h(int h)
{
     this->height = h;
}
void Rect::show()
{
    cout << "周长为 " << width*2+height*2 << endl;
    cout << "面积为 " << width*height << endl;
}
int main()
{
    Rect s1;
    s1.init(1,2);
    s1.set_w(2);
    s1.set_h(4);
    s1.show();
    return 0;
}

上一篇:C++入门(1)
下一篇:信息化工程测试验收管理制度
相关推荐
fqbqrr
2 小时前
2606C++,C++构的多态
开发语言·c++
biter down
2 小时前
从 0 到 1 搭建 Python 接口自动化测试框架(博客系统实战)
开发语言·python
小欣加油
2 小时前
leetcode56 合并区间
c++·算法·leetcode·职场和发展
lqqjuly
2 小时前
前沿算法深度解析(二)
人工智能·算法·机器学习
Yolo_TvT
3 小时前
C++:析构函数
c++
徐小夕
4 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab
4 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器
武器大师72
4 小时前
lv_binding_js 代码解读
开发语言·javascript·ecmascript
不知名的老吴
4 小时前
线程的生命周期之线程“插队“
java·开发语言·python
热门推荐
01《置身钉内》原文-可播放阅读02GitHub 镜像站点03【AI】2026 年具身智能模型和世界模型总结04Codex 下载安装指南:Windows 和 macOS 官方版下载052026 AI 编程工具终极实战指南:Cursor vs Claude Code vs Copilot,开发者该怎么选?062026 年 AI 编程工具终极横评:Cursor vs Claude Code vs Copilot vs Windsurf07【踩坑记录 | 第一篇】微软商店无法使用时,如何手动安装 OpenAI Codex?附`.msix`文件系统错误解决方法08CC-Switch 下载、安装与使用配置指南【2026.5.29】09AI科技热点日报 | 2026年6月1日10CC-Switch & Claude 基于 Linux 服务器安装使用指南