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;
}
相关推荐
lichenyang4532 小时前
React ajax中的跨域以及代理服务器
前端·react.js·ajax
呆呆的小草2 小时前
Cesium距离测量、角度测量、面积测量
开发语言·前端·javascript
一 乐3 小时前
民宿|基于java的民宿推荐系统(源码+数据库+文档)
java·前端·数据库·vue.js·论文·源码
testleaf3 小时前
前端面经整理【1】
前端·面试
好了来看下一题3 小时前
使用 React+Vite+Electron 搭建桌面应用
前端·react.js·electron
啃火龙果的兔子3 小时前
前端八股文-react篇
前端·react.js·前端框架
小前端大牛马3 小时前
react中hook和高阶组件的选型
前端·javascript·vue.js
刺客-Andy3 小时前
React第六十二节 Router中 createStaticRouter 的使用详解
前端·javascript·react.js
萌萌哒草头将军5 小时前
🚀🚀🚀VSCode 发布 1.101 版本,Copilot 更全能!
前端·vue.js·react.js
GIS之路6 小时前
OpenLayers 图层叠加控制
前端·信息可视化