C++程序设计>>

2018-04-02  本文已影响0人  五环旗

    chapter 1~4

1.

一般用

#include<iostream>

using namespace std;

#include"std_lib_facilities.h"

可以替换为以下代码

#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

using namespace std;

inline void keep_window_open(){char ch;cin>>ch}

2.命名变量时注意 名字必须以字母开头,包含字母,数字,下划线

3.错误示例,未初始化(x=3)时,使用会出错

double x;

x++;

4.安全类型转换:小容器的类型可以安全转换成大容器的类型

   char x='c'//(1 byte);

   int i=x;//(4 byte);

    double t=i//(8 byte);

5.不安全类型转换:将1 L水倒入一500 ml容器中

int a=2000//(4 byte);

char c=a;//(1 byte);

6. cout<<char('a'+1);//输出b

上一篇 下一篇

猜你喜欢

热点阅读