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;
}
相关推荐
Nan_Shu_6142 小时前
学习:ES6(2)
前端·学习·es6
命运之光6 小时前
【最新】ChromeDriver最新版本下载安装教程,ChromeDriver版本与Chrome不匹配问题
前端·chrome
星离~7 小时前
Vue响应式原理详解:从零实现一个迷你Vue
前端·javascript·vue.js
梦6508 小时前
React 简介
前端·react.js·前端框架
一只小阿乐8 小时前
react 中的判断显示
前端·javascript·vue.js·react.js·react
光影少年8 小时前
useMemo 和 React.memo区别
前端·react.js·前端框架
小沐°8 小时前
React-页码组件
前端·javascript·react.js
零一科技8 小时前
Vue3学习第三课: ref 与 reactive 选择指南
前端·vue.js
余杭子曰9 小时前
播放状态与播放序列的关系(999篇一线博客第107篇)
前端
e***U82010 小时前
前端路由懒加载实现,React.lazy与Suspense
前端·react.js·前端框架