212 // 合法的 215u // 合法的 0xFeeL // 合法的 078 // 非法的:8 不是八进制的数字 032UU // 非法的:不能重复后缀
85 // 十进制 0213 // 八进制 0x4b // 十六进制 30 // 整数 30u // 无符号整数 30l // 长整数 30ul // 无符号长整数
3.14159 // 合法的 314159E-5L // 合法的 510E // 非法的:不完整的指数 210f // 非法的:没有小数或指数 .e55 // 非法的:缺少整数或分数
| 转义序列 | [center]含义[/center] |
|---|---|
| \ | \ 字符 |
| \' | ' 字符 |
| \" | " 字符 |
| \? | ? 字符 |
| \a | 警报铃声 |
| \b | 退格键 |
| \f | 换页符 |
| \n | 换行符 |
| \r | 回车 |
| \t | 水平制表符 |
| \v | 垂直制表符 |
| \ooo | 一到三位的八进制数 |
| \xhh . . . | 一个或多个数字的十六进制数 |
#include <iostream>
using namespace std;
int main()
{
cout << "Hello\tWorld\n\n";
return 0;
}
Hello World
"hello, dear" "hello, \ dear" "hello, " "d" "ear"
#define identifier value
#include <iostream>
using namespace std;
#define LENGTH 10
#define WIDTH 5
#define NEWLINE '\n'
int main()
{
int area;
area = LENGTH * WIDTH;
cout << area;
cout << NEWLINE;
return 0;
}
const type variable = value;
#include <iostream>
using namespace std;
int main()
{
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = '\n';
int area;
area = LENGTH * WIDTH;
cout << area;
cout << NEWLINE;
return 0;
}
double& dr = 1; // 错误:需要左值 const double& cdr = 1; // ok
double temp = double(1); const double& cdr = temp;
// bc_temp_objects_not_bound_to_nonconst_ref.cpp
// compile with: /EHsc
#include "iostream"
using namespace std;
class C {};
void f(C & c) { cout << "C&" << endl; }
void f(C const & c) { cout << "C const &" << endl; }
int main() {
f(C());
}
#include <iostream>
using namespace std;
void display(int const &ref) {cout<<ref<<'\n';}
int main()
{
int i=1;
display(i);
int const anotheri=2;
display(anotheri);
display(2);
display(1+2);
display(static_cast<int>(3.14159));
}
T & my_op ( void )
{
T t;
return t;
} // The T object t got destroyed here so the
returned reference is not valid anymore.
const T & my_op ( void )
{
T t;
return t;
}
const T & my_t_obj = my_op ();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有