随笔分类 - A1 C++
摘要:```c++ #include #include #include unsigned int random_char() { std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution dis(0, 255
阅读全文
摘要:本案例实现一个test命名空间,此命名空间内有两个函数,分别为getName()和getNameSpace(); 1. 声明命名空间及函数 ```c++ namespace test{ const std::string& getName()和(); const std::string& getNa
阅读全文
摘要:static关键字可以修饰变量或者函数。 1. 声明局部静态变量 2. 声明类内静态数据成员/成员函数。 # 1、声明局部静态变量 ```c++ void test() { static int a = 1; // 静态局部变量 int b = 1; // 普通局部变量 } ``` 1. 静态局部变
阅读全文
摘要:指针:是一个变量,存储一个变量的地址。 引用:是变量的别名。 # 1、初始化 1. 指针定义时不必初始化,引用必须初始化。 2. 指针初始化时可为NULL,引用不能初始化为NULL。 ```c++ int a = 10; int *p = &a; int &y = a; cout << "a是" <
阅读全文
摘要:首先理解常亮表达式。常量表达式是指**值不会改变**,并且在**编译过程**就能计算得到结果。 1. const修饰的对象无法修改,constexpr对象在编译期间就确定且无法修改。 2. constexpr变量,编译器在编译阶段验证变量是否为一个常量表达式。 3. constexpr侧重变量初值编
阅读全文
摘要:# 1、安装插件 Microsoft Visual Studio Installer Projects  # 2、新建setup项
阅读全文
摘要:## 1.1 下载gcc https://github.com/niXman/mingw-builds-binaries/releases ## 1.2 配置环境变量bin目录 略 ## 1.3 vscode安装c/c++插件 调试运行会生成c_cpp_properties.json和tasks.j
阅读全文
摘要:1、将全局编码和项目编码一级文件编码改为【UTF-8】  2、按住快捷键:【Ctrl+Alt+Shift+/】,显示一下对话框 !
阅读全文
摘要:```c++ const int* a; // 指向常量int的指针 int *const a; // 指向int的常量指针,指针是常量 void f1(int *const a){ // 指针是常量 std::cout << *a <<std::endl; } void f2(const int*
阅读全文
摘要:# 第一种方法 必须使用5来限制参数类型是int[5],另一个参数可以指定 ```c++ void print(int m[][5],int dim1){ for(int i = 0; i!= dim1; i++){ for(int j = 0; j != 5; j++){ std::cout <<
阅读全文
摘要:```c++ // 3种形式 void comp(int arg[10]){}; // 对数组元素的个数进行限制,超过10的数组只会截取前10个 void comp(int arg[]){}; void comp(int* arg){}; ```
阅读全文
摘要:std::string to_string(int); // 例子 string str = to_string(x);
阅读全文
摘要:// string<——>wstring #include <codecvt> std::string wstring2utf8string(const std::wstring& str) { static std::wstring_convert<std::codecvt_utf8<wchar_
阅读全文
摘要:用到的技术 1、 使用easyx图形库进行绘制; 2、 使用time.h时间种子产生随机数; 3、 使用conio.h响应键盘的操作; 一、爱心的结构体 struct Point { double x, y; // 坐标 COLORREF color; // 颜色 }; 二、初始化数据 COLORR
阅读全文

浙公网安备 33010602011771号