---
# System prepended metadata

title: '**C Plus PLus**'
tags: [Tutorial, CPP]

---

# **C Plus PLus**

[![hackmd-github-sync-badge](https://hackmd.io/s9ktAOxeR0-cpspni1Sq1w/badge)](https://hackmd.io/s9ktAOxeR0-cpspni1Sq1w)

###### tags: `CPP` , `Tutorial`

---
**CONTENT**

[TOC]

___

# `IDE`

👉整合開發環境（Integrated Development Environment):

輔助程式開發人員開發軟體的應用軟體，在開發工具內部就可以輔助編寫原始碼文字、並編譯打包成為可用的程式，有些甚至可以設計圖形介面(e.g. [Scratch](https://scratch.mit.edu)、EV3)

CPP常見IDE

```
1.VS code
```
![samplePIC](https://i.imgur.com/lGe6ekQ.png)
- 需要自行架設環境
- ~~看起來還算滿電的~~
- 我都用這個(因為我很弱Orz)
```
2.Visual Studio
```
![samplePIC](https://i.imgur.com/Ou64IhZ.png)
- 一鍵安裝
- ~~微醜~~
```
3.Atom
```
![samplePIC](https://i.imgur.com/o8R3i2s.png)
- 需要自行架設環境
- ~~看起來還算滿電的~~
- ~~高端的電神都用這個~~

```
4.DEV C++
```
![samplePIC](https://i.imgur.com/U7HbzFN.png)
- 一鍵完整安裝
- 有些電神在用
- ~~不好看~~
```
5.Code Block
```
![](https://i.imgur.com/EQA83iU.png)
- 一鍵完整安裝
- 有些電神在用
- ~~不好看 但比Dev C==好看一點點~~

以上純屬個人看法 還是要看大家自己的習慣啦😗😗

---

> Download Link(For Windows):
> 
> ⭐[VS code](https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user)
>
> ⭐[Visual Studio](https://visualstudio.microsoft.com/zh-hant/thank-you-downloading-visual-studio/?sku=Community&rel=16)
>
> ⭐[Atom](https://atom.io/download/windows_x64)
>
> ⭐[Dev C++](https://sourceforge.net/projects/orwelldevcpp/files/latest/download)
>
> ⭐[Code Block](https://sourceforge.net/projects/codeblocks/files/Binaries/20.03/Windows/codeblocks-20.03-setup.exe/download)

---

# `#include`

👉指示詞(`#include`)

告訴程式需要用到哪些語法的檔案(e.g:`stdio.h`,`iostream`)

⚙️**語法**:
```cpp=1
// #include <標頭檔位置>
#include <iostream>
// #include "標頭檔位置"
#include "iostream"
```

常見標頭檔案:
```
1.iostream
```
- `iostream`
  - Input、Output >> 輸入/輸出
  - stream >> 流(一連串從I/O設備讀寫的字符)
- `C++`用於數據的流式輸入與輸出的頭文件，屬於`C++`標準程式庫的一部分

```
2.stdio.h
```
- `stdio.h`
  - std >> standard
  - io >> I/O
- C語言為輸入輸出提供的標準標頭文件

```
3.iomanip
```
- `iomanip`
  - io >> I/O
  - manip >> manipulator(操作器)
- 將I/O的格式進行控制(e.g [四捨五入](https://pedia.cloud.edu.tw/Entry/WikiContent?title=四捨五入&search=四捨五入))

```
4.windows.h
```
- `windows`
  - windows作業系統
- 適用於C/C++的Windows特定的標頭文件

```
5.bits/stdc++.h
```
- `bits/stdc++.h`
  - bits/ >> 儲存於bits資料夾下
  - std >> standard
- 萬用標頭檔
```cpp=1
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// 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>

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

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
```

```
6.math.h
```
- C標準函數庫中的頭文件(標頭檔)。提供用於常用高級數學運算的運算函數

```
7.cmath
```
- C++標頭檔高級數學處理標頭檔 將相關名稱加入std命名空間

> cmath v.s. math.h
> |     | cmath | math.h|
> | --- | --- | ---|
> | 語言 | C++ 專用 | C or C++|
> | 備註 | 在`namespace std` 下建置的 | -|

---

# `Default DATA Type`

👉資料型態(Data Type):
在電腦的世界中，對於各種資料的型態定義是不一樣的，接著我們要來介紹C++中資料的型態

⚙️常見資料型態

---
```
1.int
```
- 整數
- 位元組:4
- 資料範圍:`-2,147,483,648`<= `x` <= `2,147,483,647`
``` 
2,147,483,648 = 2^31
-(2^31) <= x <= (2^31)-1
```

```
2.unsigned int
```
- 整數
- 位元組:4
- 資料範圍:`0`<= `x` <= `4,294,967,295`
``` 
4,294,967,296 = 2^32
0 <= x <= (2^32)-1
```

```
3.long long
```
- 整數
- 位元組:8
- 資料範圍:`-9,223,372,036,854,775,808` <= `x` <= `9,223,372,036,854,775,807`
```
(9,223,372,036,854,775,808) = 2^63
 -(2^63) <= x <= (2^63)-1
```

```
4. long
```
- 整數
- 位元組:4
- 資料範圍:`-2,147,483,648` <= `x` <= `2,147,483,647`
```
2,147,483,648 = 2^31
-(2^31) <= x <= (2^31)-1
```
---
```
1.char
```
- 字元
- 位元組:1
- 資料範圍: [ASCII](https://zh.wikipedia.org/wiki/ASCII)

```
2.string
```
- 字串
- 位元組
- 資料範圍

---
```
1.float
```
- 浮點數
- 