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;
}
相关推荐
铁皮饭盒几秒前
成为AI全栈 - 第1课:后端到底是干嘛的?一张图拆解登录
前端·后端·ai编程
tingting01193 分钟前
dns域名信息收集
linux·服务器·前端
暗不需求7 分钟前
用 Vue 3 搓一个 AI 冰球形象生成器:从源码到 Coze 工作流全解析
前端·vue.js·ai编程
Asmewill13 分钟前
MCP学习笔记
前端
小小199215 分钟前
vue 单页面请求
开发语言·前端·javascript
不会敲代码118 分钟前
从 URL 到页面展示,还有哪些你忽略的底层细节?(DNS 与传输篇)
前端·面试
无心使然26 分钟前
Openlayers调用ArcGis要素服务之一 ——要素查询 (/query)
前端·javascript·数据可视化
ZC跨境爬虫26 分钟前
跟着 MDN 学 HTML day_1:(全套原生Input+表单结构拆解)
前端·css·ui·html
焰火199931 分钟前
[前端]单文件上传组件
前端·vue.js
kyriewen1132 分钟前
Next.js部署:从本地跑得欢,到线上飞得稳
开发语言·前端·javascript·科技·react.js·前端框架·ecmascript