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;
}
相关推荐
星火开发设计44 分钟前
模板参数:类型参数与非类型参数的区别
java·开发语言·前端·数据库·c++·算法
cc.ChenLy3 小时前
【CSS进阶】毛玻璃效果与代码解析
前端·javascript·css
何中应3 小时前
使用Jenkins部署前端项目(Vue)
前端·vue.js·jenkins
3秒一个大3 小时前
JWT 登录:原理剖析与实战应用
前端·http·代码规范
NEXT063 小时前
2026 技术风向:为什么在 AI 时代,PostgreSQL 彻底成为了全栈工程师的首选数据库
前端·数据库·ai编程
NEXT063 小时前
拒绝“盲盒式”编程:规范驱动开发(SDD)如何重塑 AI 交付
前端·人工智能·markdown
@大迁世界4 小时前
仅用 CSS 实现元素圆形排列的方法
前端·css
JosieBook4 小时前
【Vue】15 Vue技术——Vue计算属性简写:提升代码简洁性的高效实践
前端·javascript·vue.js
weixin199701080165 小时前
Lazada商品详情页前端性能优化实战
前端·性能优化
星火开发设计5 小时前
异常规范与自定义异常类的设计
java·开发语言·前端·c++