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;
}
相关推荐
神经毒素9 分钟前
WEB安全--XSS--DOM破坏
前端·web安全·xss
不简说32 分钟前
sv-print可视化打印组件不完全指南③
前端·javascript·vue.js
前端摸鱼杭小哥34 分钟前
Vue 开发者狂喜!我在 React 中完美复刻了 v-if/v-for 指令
前端·vue.js·react.js
kovli37 分钟前
红宝书第四讲:JavaScript原始值与引用值行为差异详解
前端·javascript
竹苓38 分钟前
CSS Grid布局:从入门到放弃再到真香
前端
1_2_3_39 分钟前
深入理解 Git 子模块:优化项目管理的利器
前端·github
前端开发同学44 分钟前
程序员必看!被盒模型逼疯的我,看完迎刃而解😎
前端·html
阳树阳树1 小时前
Svelet 原理初探
前端·javascript
wordbaby1 小时前
深入理解 CSS 字体加载与解析机制
前端
Mintopia1 小时前
Node.js 之 fs 模块深入解析与实践
前端·javascript·node.js