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;
}
相关推荐
Amumu1213823 分钟前
CSS简介
前端·css
Yzw37 分钟前
当vue.diff遇上了扩展运算符(...)
前端
前端不开发37 分钟前
在任意网页里“召唤”一个火柴人:一次有趣的 JavaScript Hack
前端·javascript
whatever who cares1 小时前
Java Web 架构全组件详解
java·前端·架构
DevDengChao1 小时前
[Aliyun] [FC] 如何使用 website-fc-serve 插件部署静态网站
前端·后端
前端拿破轮1 小时前
利用Github Page + Hexo 搭建专属的个人网站(一)
前端·人工智能·后端
q1cheng1 小时前
基于Spring Boot + Vue项目online_learn的用户登录认证全流程分析
前端
大时光1 小时前
gsap 配置解读 --2
前端
万岳科技程序员小金1 小时前
AI数字人小程序源码开发全流程实战:前端交互+后端算法部署指南
前端·人工智能·软件开发·ai数字人小程序·ai数字人系统源码·ai数字人软件开发·ai数字人平台搭建
白开水丶1 小时前
vue3源码学习(五)ref 、toRef、toRefs、proxyRefs 源码学习
前端·vue.js·学习