C++详解之基本结构

对于C++,你了解多少呢?在学习C++的漫漫长路上,基本结构可是必须掌握的东西。这一章,我就带大家聊聊“基本结构”。

目录

1、头文件

2、命名空间

3、主函数

 4、语法

Q1:C++为什么每个句子后面都要加分号

5、return 0;语句

异常的返回值:

Ⅰ、process exited with return value 3221225477

Ⅱ、process exited with return value 3221225725

Ⅲ、process exited with return value 3221225620


1、头文件

C++常用的头文件包括:

  1. iostream:用于输入输出操作的头文件,包括cincoutendl等。

  2. iomanip:用于格式化输出操作的头文件,包括setwsetprecision等。

  3. cmath:用于数学运算操作的头文件,包括数学函数如sqrtsincos等。

  4. cstdlib:用于系统调用、随机数生成等操作的头文件,包括randatoiexit等。

  5. cstring:用于字符串操作的头文件,包括strlenstrcpystrcat等。

  6. vector:用于向量操作的头文件,包括vectorpush_backpop_back等。

  7. algorithm:用于算法操作的头文件,包括sortreversefind等。

  8. string:用于字符串处理的头文件,包括stringsubstrfind等。

  9. fstream:用于文件输入输出操作的头文件,包括fstreamifstreamofstream等。

  10. ctime:用于时间处理的头文件,包括timeclock等。

这些头文件,只是C++头文件的一小部分。更多的头文件,会在今后的学习中学到。

那有的同学就问了,那么多头文件,该怎么记忆呢?

其实没有关系,c++头文件中还有一个大BOSS:

#include<bits/stdc++.h>

这个头文件可厉害了,他有着几乎所有C++的头文件:

Tips:以下为stdc++.h的内容,可跳过

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cuchar>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
  • 35
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值