doc/docs/CPlusPlus-main/05_C++的变量.md
sairate fa9377e4ae docs(book): 添加现代 C++教程及相关代码
- 新增现代 C++ 教程的 Preface 章节,包括英文和中文版本
- 添加 C++ Primer 练习代码
- 新增 Learn C++ 教程的 C++ 开发简介章节
- 添加头文件解析文档
- 更新 mkdocs.yml,包含新教程的目录结构
- 修改项目设置,使用 Python 3.10环境
2025-07-08 09:52:45 +08:00

38 lines
768 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# C++的变量
# 1. 变量
① 变量的作用就是就是给一段指定的内存空间起名,方便操作这段内存。
② 语法:数据类型 变量名 = 初始值;
③ 变量存在的意义:方便我们管理内存空间。
④ 每一段内存都有一个地址编号。
⑤ C++规定在创建一个常量或变量时,必须要指出相应的数据类型,否则无法给变量分配内存。
```python
#include <iostream>
using namespace std;
int main()
{
//变量创建的语法数据类型 变量名 = 变量初始值
int a = 10;
cout << "a = " << a << endl; // 输出语句 cout << "提示语" << 变量 << endl;
system("pause");
return 0;
}
```
运行结果:
- a = 10
- 请按任意键继续. . .