------------------------------------------------------------------
经典问题1:c/c++ 程序设计 ---赋值语句
-------------------------------------------------------------------
1)面试题:what does the follow program print?
1 #include <iostream>
2
3 using namespace std;
4
5 int vac = 3;
6
7 int main ()
8 {
9 int vac = 10;
10 ::vac++; //知识点:全局作用域::3+1=4
11 cout<<::vac<<endl;
12 cout<<vac<<endl;
13
14 return 0;
15 }
16
----------------
result:
$ ./a.out
4
10
----------------
经典问题1 :c/c++ 程序设计 ---赋值语句
最新推荐文章于 2024-02-29 22:29:22 发布