C++
C++的一些学习
路和远方
这个作者很懒,什么都没留下…
展开
-
QT信号与槽
QT信号与槽使用系统的信号与槽// 设置按钮的点击事件// 创建按钮QPushButton * btn = new QPushButton;btn->setParent(this);btn->setText("关闭");btn->setFixedSize(100,30);setWindowTitle("信号与槽");setFixedSize(600,600);btn->move(100,100);// 设置按钮的点击事件 ->关闭窗口connect(bt原创 2022-05-27 15:32:02 · 79 阅读 · 0 评论 -
C++之宏函数和内联函数
宏函数和内联函数// 内联函数解决宏定义函数的问题#define GET_SUM(A,B) A+Binline int get_sum(int a,int b){ return a + b;}// main 函数int main(){ // 调用宏函数 int sum = GET_SUM(1,2) * 10; // 预期效果 30 实际结果 21 ...原创 2019-12-02 14:20:36 · 109 阅读 · 0 评论 -
C++之类对象
类构造方法class Person{ public: Person(){ cout << "无参构造函数调用" << endl; } Person(int p_age){ cout << "有参构造函数调用" << endl; age = p_age; };...原创 2019-12-02 15:41:05 · 93 阅读 · 0 评论 -
C++之引用
C++之引用void swap(int * a ,int * b){ int temp = *a; *a = *b; *b = temp;}void swapC(int &a,int &b){ int temp = a; a = b; b = temp;}int & getValue(){ int a =...原创 2019-12-02 09:59:59 · 81 阅读 · 0 评论 -
C++的增强
C++的增强#define _CRT_SECURE_NO_WARNINGS#include <iostream> // 标准的输入输出流using namespace std; // 命名空间 防止命名冲突#include <cstring>// 1.全局变量检测增强,不能重复定义// int a;// int a = 10;// 2.函数检测增强,必...原创 2019-11-29 18:09:39 · 156 阅读 · 0 评论 -
C++命名空间namespace
C++命名空间namespace#define _CRT_SECURE_NO_WARNINGS#include <iostream> // 标准的输入输出流using namespace std; // 命名空间 防止命名冲突#include <cstring>// 1.命名空间下可以放变量 函数 结构体 类// 2.命名空间必须定义在全局作用域下name...原创 2019-11-29 15:09:51 · 157 阅读 · 0 评论 -
C++之helloworld
C++之helloworld#include <iostream> // 标准的输入输出流using namespace std; // 命名空间 防止命名冲突// main 函数int main(){ // 标准输出 // << 拼接功能 // endl 结束换行 cout << "hello world" <...原创 2019-11-29 15:04:57 · 150 阅读 · 0 评论 -
C++之异常
C++之异常简单案例int divide(int a,int b){ if(b == 0){ throw -1; } return a/b;}// main 函数int main(){ // 异常 int a = 10; int b = 0; try{ int ret = divide(a,b);...原创 2019-12-03 16:33:07 · 73 阅读 · 0 评论 -
C++之文件操作
C++之文件操作标准输入流#define _CRT_SECURE_NO_WARNINGS#include <iostream> // 标准的输入输出流using namespace std; // 命名空间 防止命名冲突#include <cstring>#include <stdexcept> // 系统异常类// main 函数int m...原创 2019-12-03 18:04:50 · 118 阅读 · 0 评论