forked from chihyang/CPP_Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer02_27.cpp
More file actions
26 lines (25 loc) · 944 Bytes
/
Copy pathExer02_27.cpp
File metadata and controls
26 lines (25 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Warning: This is for verification. It cannot be compiled successfully by every compiler.
// The problem lies in line 12, 13.
#include<iostream>
int main()
{
int i = 3;
// (f), the primary problem is that r2 isn't initialized. Whether it's compiled
// successfully depends on compiler if initialization is completed. The const after
// & is redundant.
const int &const r2;
const int &const r3 = i;
return 0;
}
// ******compile info under g++******
// Exer2_27.cpp: In function 'int main()':
// Exer2_27.cpp:6:19: error: 'const' qualifiers cannot be applied to 'const int&'
// const int &const r2 = i;
// ******compile info under cl******
// Exer2_27.cpp
// Exer2_27.cpp(6) : warning C4227: 使用了记时错误: 忽略引用上的限定符
// Microsoft (R) Incremental Linker Version 12.00.40629.0
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// /out:./obj/Exer2_27.exe
// ./obj/Exer2_27.obj