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;
}
相关推荐
anOnion1 小时前
构建无障碍组件之Carousel Pattern
前端·html·交互设计
ssshooter1 小时前
Tauri 2 iOS 开发避坑指南:文件保存、Dialog 和 Documents 目录的那些坑
前端·后端·ios
Можно2 小时前
深入理解 ES6 Proxy:与 Object.defineProperty 的全面对比
前端·javascript·vue.js
Birdy_x2 小时前
接口自动化项目实战(1):requests请求封装
开发语言·前端·python
天天向上10243 小时前
vue el-table实现拖拽排序
前端·javascript·vue.js
柳杉4 小时前
Three.js × Blender:从建模到 Web 3D 的完整工作流深度解析
前端·javascript·数据可视化
reembarkation5 小时前
vue3中使用howler播放音频列表
前端·vue.js·音视频
手握风云-5 小时前
基于 Java 的网页聊天室(三)
服务器·前端·数据库
weixin199701080165 小时前
《识货商品详情页前端性能优化实战》
前端·性能优化
Forever7_5 小时前
重磅!Vue3 手势工具正式发布!免费使用!
前端·前端框架·前端工程化