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;
}
相关推荐
中微子13 分钟前
JavaScript事件循环机制:面试官最爱问的10个问题详解
前端
Eighteen Z21 分钟前
CSS揭秘:10.平行四边形
前端·css·css3
拾光拾趣录29 分钟前
虚拟DOM
前端·vue.js·dom
爱学习的茄子29 分钟前
JavaScript事件循环深度解析:理解异步执行的本质
前端·javascript·面试
1024小神30 分钟前
cocos游戏开发中多角色碰撞,物理反弹后改变方向的实现逻辑
前端·javascript
摆烂为不摆烂34 分钟前
😁深入JS(五): 一文让你完全理解 hash 与 history 路由,手写前端路由
前端
1024小神34 分钟前
cocos游戏开发中,如何制作一个空气墙
前端·javascript
爱编程的喵35 分钟前
深入理解JavaScript事件循环机制:从同步到异步的完整解析
前端·javascript
202636 分钟前
11. vite打包优化
前端·javascript·vite
拾光拾趣录40 分钟前
组件封装的⼀些基本准则
前端·前端工程化