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 分钟前
前端转全栈,要学会后端看项目的思维
前端·后端·ai编程
oil欧哟12 分钟前
AI Agent 常用操作入门:独立目录、Plan 模式与跨话题交接指南
前端
孟陬24 分钟前
Foobar 技术周刊 #161:AI 录屏员工屏幕训练 SOP,被当做「动物园的猴子」是否触犯隐私?
前端·后端·程序员
1-1=038 分钟前
Vue 混入(Mixin)和 2.插件 (Plugins)
前端·vue.js
-梅1 小时前
linux(番外)线程,锁,条件变量封装;日志与线程池
linux·c语言·前端·c++
Rain的Java大神之路1 小时前
前端转 Java 全栈:用 AI 两天交付一个能跑的 Demo,踩坑全记录
java·前端·后端
星落梦生2 小时前
Tlias前端案例涉及知识点 (14)
开发语言·前端·javascript
Moment2 小时前
27B 的本地模型也能做知识图谱?太强了!😍😍😍
前端·后端·面试
维克兜率天3 小时前
【维克】KDJ量化实战:如何用它判断买卖点?
前端
维克兜率天5 小时前
【维克】RSI相对强弱指数:判断多空力量的温度计
前端