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;
}
相关推荐
走粥2 分钟前
选项式API与组合式API的区别
开发语言·前端·javascript·vue.js·前端框架
We་ct5 分钟前
LeetCode 12. 整数转罗马数字:从逐位实现到规则复用优化
前端·算法·leetcode·typescript
方安乐13 分钟前
react笔记之useMemo
前端·笔记·react.js
清风细雨_林木木21 分钟前
react 中 form表单提示
前端·react.js·前端框架
小二·28 分钟前
Python Web 开发进阶实战:边缘智能网关 —— 在 Flask + MicroPython 中构建轻量级 IoT 边缘推理平台
前端·python·flask
TOPGUS30 分钟前
解析200万次对话数据:ChatGPT引用内容的核心特征与优化策略
前端·人工智能·搜索引擎·chatgpt·seo·数字营销
羊仔AI探索38 分钟前
前端已死,未来已来,谷歌Gemini 3 Pro杀回来了!
前端·人工智能·ai·aigc
快起来搬砖了41 分钟前
UniApp/Vue2 通用工具函数库(完整版):覆盖校验、格式、业务全场景
前端·uni-app
GGGG寄了1 小时前
HTML——图像标签及多媒体标签
前端·html
小小码农Come on1 小时前
QPushButton QSS(一):按钮常用qss
前端·javascript·css·qt5