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;
}
相关推荐
Muen12 分钟前
iOS设计模式-外观Facade
前端
Cobyte36 分钟前
21.Vue Vapor 组件的实现原理
前端·javascript·vue.js
前端双越老师36 分钟前
我从 0 开发的 AI Agent 智语项目发布了
前端·node.js·agent
橙某人38 分钟前
LogicFlow 工作流撤销与重做:从「全量快照」到「命令模式」🎯
前端·vue.js
铁皮饭盒1 小时前
Rust版Bun1.4之前, 盘点Bun1.3新特性
前端·javascript·后端
恋猫de小郭1 小时前
如何让 AI 快速搭建一套生产 Agent ?全面理解 Agent 架构。
前端·人工智能·ai编程
Csvn1 小时前
Vite 构建缓存优化:二次构建从 15s 降到 2s 的实战方案
前端
晓得迷路了1 小时前
栗子前端技术周刊第 135 期 - Vite 8.1、Rspack 2.1、Babel 8.0...
前端·javascript·vite
你听得到112 小时前
用户说 App 卡,但说不清在哪?我把 Flutter 监控 SDK 升级成了链路观测工作台
前端·flutter·性能优化