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;
}
相关推荐
晓得迷路了2 分钟前
栗子前端技术周刊第 133 期 - Angular v22、React 编译器 Rust 版、pnpm 11.5...
前端·javascript·css
一个被程序员耽误的厨师4 分钟前
02-架构篇-前端怎么反客为主把AI编排权拿回到自己手里
前端·人工智能·架构
羊羊小栈11 分钟前
基于混合检索RAG的食品生产质量问答系统(BGE_BM25_大语言模型)
前端·人工智能·语言模型·自然语言处理·毕业设计·大作业
烤代码的吐司君12 分钟前
Redis 服务配置与使用
前端·bootstrap·html
之歆15 分钟前
Ajax 基础技术深度解析:XHR 从入门到跨域
前端·ajax·okhttp
怕浪猫16 分钟前
Electron 开发实战(十四):实战项目|从零搭建轻量化桌面代码编辑器
前端·electron·node.js
放下华子我只抽RuiKe516 分钟前
FastAPI 全栈后端(七):测试与自动化
运维·前端·人工智能·react.js·前端框架·自动化·fastapi
晓131319 分钟前
【Cocos Creator 3.x】篇——第五章 项目实战优化技术
前端·javascript·游戏引擎
有梦想的程序星空24 分钟前
【环境配置】使用 Vue CLI 构建 Vue 项目脚手架完整指南
前端·javascript·vue.js
之歆29 分钟前
Ajax 进阶:跨域、CORS、JSONP 与请求封装实战
前端·javascript·ajax