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;
}
相关推荐
有诺千金32 分钟前
VUE3入门很简单(4)---组件通信(props)
前端·javascript·vue.js
2501_9447114333 分钟前
Vue-路由懒加载与组件懒加载
前端·javascript·vue.js
雨季6661 小时前
Flutter 三端应用实战:OpenHarmony “心流之泉”——在碎片洪流中,为你筑一眼专注的清泉
开发语言·前端·flutter·交互
换日线°1 小时前
前端3D炫酷展开效果
前端·3d
广州华水科技1 小时前
大坝变形监测的单北斗GNSS技术应用与发展分析
前端
Dontla1 小时前
浏览器localStorage共享机制介绍(持久化客户端存储方案)本地存储冲突、iframe、XSS漏洞、命名空间隔离
前端·网络·xss
霍理迪1 小时前
JS其他常用内置对象
开发语言·前端·javascript
tao3556672 小时前
HTML-03-HTML 语义化标签
前端·html
小马_xiaoen2 小时前
IndexedDB 从入门到实战:前端本地大容量存储解决方案。
前端
jiayong232 小时前
Vue2 与 Vue3 常见面试题精选 - 综合宝典
前端·vue.js·面试