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;
}
相关推荐
copyer_xyf11 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
gqk0111 小时前
Delegate.Target/ Method
前端·ui·xhtml
有梦想的程序星空12 小时前
【环境配置】Vue3项目离线化本地部署echarts全攻略
前端·javascript·vue·echarts
IT_陈寒12 小时前
被Vite的动态导入坑了一整天,原来问题出在这
前端·人工智能·后端
薛先生_09912 小时前
vue-路由重定向
前端·javascript·vue.js
橘子星13 小时前
基于 ES6 语法的 NLP 任务模块化开发实践
前端·javascript
玉宇夕落13 小时前
Props的传递学习
前端
月光刺眼13 小时前
JS 底层执行机制探讨:执行上下文、变量提升与调用栈
前端·javascript
|_⊙13 小时前
Linux 信号
运维·服务器·前端
ZC跨境爬虫13 小时前
跟着 MDN 学 JavaScript day_1:什么是 JavaScript?
开发语言·前端·javascript·ecmascript