数据类型
第一个C++程序
#include <iostream> //头文件引用 #include表示引用
using namespace std;//命名空间
void main () //主函数
{
unsigned short a;
a=65535;
cout << a; //执行和输出 cout:输出流 <<将a传送到输出流:
cout << "Hello World!\n";
//return 0;
}
常量及符号
常量的声明:const 数据类型 数据名=值
1、整形常量:
a、8进制:以0开头取值在0~7,比如0567、01777,不合法表示:0999/0778;
b、16进制:0x开头表示;
2、实型常量(浮点数):
两种表现形式:
a、小数表示
b、指数表示(科学计数法)
L表示长整形,U表示无符号
3、字符常量、字符串常量:
' ':字符常量.
"":字符串常量.
数据输入与输出
C++中的关键字
asm | auto | bread | case | catch | char | class | const | continue |
default | delete | do | double | else | enum | extern | float | for |
friend | goto | if | inline | int | long | new | operator | overload |
private | protected | public | register | return | short | signed | sizeof | static |
struct | switch | this | template | throw | try | typedef | union | unsigned |
virtual | void | volatile | while |
常用数据类型
![](https://img-blog.csdnimg.cn/img_convert/d7125b8a4fd30d151fcc53a136248b45.png)