A::A() : _b(XXX,XXX)解析
来源:互联网 发布:淘宝五十字好评有积分 编辑:程序博客网 时间:2024/06/05 15:54
1)A::A() : _b(XXX,XXX); 冒号是初始化的作用,即把xxx,xxx赋值给B类型的_b
2)成员初始化列表
3)_b 是A的成员变量,
A的构造的时候初始了变量_b
你先去看看构造函数的书写格式,你就懂了。。
4)初始化; 比如常量的话就只能采用这种方式初始化唉
5)说明A()函数,是A中的,指明所属;: _b(XXX,XXX); 指的是初始化变量。
===============================================================================================
C++中双冒号作用域解析符的含义(转载)
http://blog.csdn.net/lychee007/article/details/5386039
先把各家的解释复制在这里,意思都差不多。
You can tell the compiler to use the global identifier rather than the local identifier by prefixing the identifier with ::, the scope resolution operator.
- :: identifier
- class-name :: identifier
- namespace :: identifier
Remarks
The identifier can be a variable or a function.
If you have nested local scopes, the scope resolution operator does not provide access to identifiers in the next outermost scope. It provides access to only the global identifiers.
Example
This example has two variables named amount. The first is global and contains the value 123. The second is local to the main function. The scope resolution operator tells the compiler to use the global amount instead of the local one.
- // expre_ScopeResolutionOperator.cpp
- // compile with: /EHsc
- // Demonstrate scope resolution operator
- #include <iostream>
- using namespace std;
- int amount = 123; // A global variable
- int main() {
- int amount = 456; // A local variable
- cout << ::amount << endl // Print the global variable
- << amount << endl; // Print the local variable
- }
IBM XL C/C++ for AIX, V10.1
Scope resolution operator :: (C++ only)
- int count = 0;
- int main(void)
- {
- int count = 0;
- ::count = 1; // set global count to 1
- count = 2; // set local count to 2
- return 0;
- }
You can also use the class scope operator to qualify class names or class member names. If a class member name is hidden, you can use it by qualifying it with its class name and the class scope operator.
- #include <iostream>
- using namespace std;
- class X
- {
- public:
- static int count;
- };
- int X::count = 10; // define static data member
- int main ()
- {
- int X = 0; // hides class type X
- cout << X::count << endl; // use static member of class X
- }
C++ 双冒号作用域转换操作符
使用双冒号操作符 (::) 可以用以下名称限定具有全局作用域的 C++ 成员函数、顶级函数或变量:
- 重载名(不同参数类型使用同一名称)
- 二义名(不同类中使用同一名称)
- #include <iostream>
- using namespace std;
- int n = 12; // A global variable
- int main()
- {
- int n = 13; // A local variable
- cout << ::n << endl; // Print the global variable: 12
- cout << n << endl; // Print the local variable: 13
- }
- A::A() : _b(XXX,XXX)解析
- 解析“a=xxx;b=xxx;c=xxx;.....”,使用"Uson"
- make xxx Is a directory
- struts2中<a: href="xxx">xxx</a>与<s:a href="xxx">xxx</s:a>的区别
- xxx is not a function
- Only a type can be imported. com.xxx.xxx.XXX resolves to a package 解决方法
- Only a type can be imported. com.xxx.xxx.XXX resolves to a package 解决方法
- Only a type can be imported. com.xxx.xxx.XXX resolves to a package 解决方法 .
- make xxx Is a directory. Stop.
- A Bullshit Weekend in Suck XXX
- The xxx collides with a package/type
- xxx cannot be resolved to a type
- xxx cannot be resolved to a type
- html中报错:xxx is not a function
- 【C++竞赛 A】xxx的项链
- Launching XXX has encountered a problem解决办法
- XXX cannot be resolved to a type!
- The xxx collides with a package/type
- Delphi 任务栏的自动隐藏与隐藏问题
- AIR创始子窗体的两种方法
- 关于Android中传递数据的一些讨论
- 创建AIR应用时常犯的10个错误
- JSP2自定义标签(二)——带属性的标签
- A::A() : _b(XXX,XXX)解析
- vi命令
- 浅谈:国内软件公司为何无法做大做强
- FILTER:progid:DXImageTransform.Microsoft.Gradient使用
- js编码处理
- Java_09_19课堂总结
- 三十分钟掌握STL(Using STL)
- [评论]为什么中国的程序员技术偏低
- socketProxy