QT day 2

cpp 复制代码
#include <iostream>

using namespace std;
class rect
{
private:
    int width;
    int height;
public:
    void init(int width , int height);
    void set_w(int width);
    void set_h(int height);
    void show();
};
void rect::show()
{
    cout << width << " ";
    cout << height << endl;
}
void rect::init(int width, int height)
{
    this -> width=width;
    this -> height=height;
}
void rect::set_w(int width)
{
    this -> width=width;
}
void rect :: set_h(int height)
{
    this -> height=height;
}

int main()
{
    rect rec;
    rec. init (3,4);
    rec.show();
    rec.set_w(7);
    rec.show();
    rec.set_h(10);
    rec.show();

    return 0;
}
相关推荐
变与不变8064 小时前
js函数与封装详细解答
前端·javascript·vue.js
南雨北斗5 小时前
Vue 3 项目中的拦截器的作用和写法(动态设置响应头适配表单文件上传)
前端
涛涛ing5 小时前
125秒到10秒:TypeScript 7.0用Go重写编译器,前端圈等了14年
前端
爱勇宝5 小时前
初创公司的“自己人”,到底能当多久?
前端·后端·程序员
晴天165 小时前
前端模块化规范全景解析:CommonJS、AMD、ESM、UMD
前端
三十而立洋6 小时前
深入理解 npm:从核心机制到常用命令全解析
前端·前端工程化
Canace6 小时前
最新版 Codex 工作流的问题
前端·人工智能·agent
变与不变8066 小时前
引用类型、内存原理与对象
开发语言·前端·javascript
jearry6 小时前
给 C++ 老程序补现代 UI:WebView2 多入口资源加载与虚拟主机名实践
前端
打呵欠的猫6 小时前
让 AI 帮你写 Git Commit Message:从"fix bug"到语义化提交只需一个 Hook
前端·ai编程