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;
}
相关推荐
郭wes代码22 分钟前
纯 CSS+JS 实战:手搓一张支持自定义的通用金色电子奖状(万字详细拆解)
前端·javascript·css
阿黎梨梨1 小时前
React 表单处理与性能优化:从入门到进阶
前端·react.js
Whbbit19991 小时前
发布自己的 shadcn-vue 扩展组件,并支持 CLI 安装
前端·开源
Tian_Hang1 小时前
Vue3 父子组件通讯
前端·javascript·vue.js
breeze jiang1 小时前
React memo、useCallback 与 useMemo:父组件多状态时如何减少无效渲染
前端·javascript·react.js
小黑技术栈1 小时前
Java前端基础到入门——16day
java·开发语言·前端
朱涛的自习室2 小时前
从 Prompt 到 Graph:AI 工程的进化史
android·前端·人工智能
敲代码的玉米C3 小时前
让两个模型一写一审
前端·人工智能·架构
代码不加糖3 小时前
common.js和es6中模块引l入的区别?
前端·javascript·es6
qq83443103 小时前
一款纯前端的excel控件,XuY_Sheet 电子表格组件教程
前端·excel·教程·luckysheet·xuy_sheet控件·前端表格控件