- 新增现代 C++ 教程的 Preface 章节,包括英文和中文版本 - 添加 C++ Primer 练习代码 - 新增 Learn C++ 教程的 C++ 开发简介章节 - 添加头文件解析文档 - 更新 mkdocs.yml,包含新教程的目录结构 - 修改项目设置,使用 Python 3.10环境
144 lines
2.7 KiB
Plaintext
144 lines
2.7 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"# C++的关键字"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"# 1. 关键字"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"① 关键字是C++中预先保留的单词(标识符)。\n",
|
||
"\n",
|
||
"② 在定义变量或者常量的时候,不要用关键字。"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 1.1 int关键字"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"#include <iostream>\n",
|
||
"using namespace std;\n",
|
||
"\n",
|
||
"int main()\n",
|
||
"{\n",
|
||
"\n",
|
||
" // int int = 10; // 错误,第二个int是关键字,不可以作为变量的名称\n",
|
||
"\n",
|
||
" system(\"pause\");\n",
|
||
"\n",
|
||
" return 0;\n",
|
||
"\n",
|
||
"}"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"运行结果: \n",
|
||
" - 请按任意键继续. . ."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 1.2 sizeof关键字"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"① sizeof关键字可以统计数据类型所占内存大小。\n",
|
||
"\n",
|
||
"② sizeof关键字,语法:sizeof ( 数据类型 / 变量 )"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"#include <iostream>\n",
|
||
"using namespace std;\n",
|
||
"\n",
|
||
"int main()\n",
|
||
"{\n",
|
||
"\n",
|
||
" cout << \"short 类型所占内存空间为:\" << sizeof(short) << endl;\n",
|
||
"\n",
|
||
" system(\"pause\");\n",
|
||
"\n",
|
||
" return 0;\n",
|
||
"\n",
|
||
"}"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"运行结果: \n",
|
||
" - short 类型所占内存空间为:2 \n",
|
||
" - 请按任意键继续. . ."
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3.6.3",
|
||
"language": "python",
|
||
"name": "python3.6.3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.6.3"
|
||
},
|
||
"toc": {
|
||
"base_numbering": 1,
|
||
"nav_menu": {},
|
||
"number_sections": false,
|
||
"sideBar": true,
|
||
"skip_h1_title": false,
|
||
"title_cell": "Table of Contents",
|
||
"title_sidebar": "Contents",
|
||
"toc_cell": false,
|
||
"toc_position": {},
|
||
"toc_section_display": true,
|
||
"toc_window_display": true
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 4
|
||
}
|