OverLoading and Scope
来源:互联网 发布:autocad mac 中文版 编辑:程序博客网 时间:2024/05/18 13:30
When we call print, the compiler first looks for a declaration of that name. It finds the local declaration for print that takes an int. Once the name is found, the compiler does no further checks to see if the name exists in an outer scope. Instead, the compiler assumes that this declaration is the one for the name we are using. What remains is to see if the use of the name is valid.
The first call passes a string literal but the function parameter is an int. A string literal cannot be implicitly converted to an int, so the call is an error. The print(const string&) function, which would have matched this call, is hidden and is not considered when resolving this call.
When we call print passing a double, the process is repeated. The compiler finds the local definition of print(int). The double argument can be converted to an int, so the call is legal.
- OverLoading and Scope
- 10.6 Signatures and overloading
- Overloading And Overriding
- Overloading '+' VS. StringBuilder and StringBuffer
- Method of Overriding and Overloading
- Function overloading and const keyword
- Name Mangling and Function Overloading
- C++ Overloading (Operator and Function)
- overloading
- Overloading the increment and decrement operators (非常好)
- Overloading with Widening、Boxing and Var-args
- sample code about overloading new and delete
- overloading stream insertion and stream extraction operators
- Scope And Closures
- AngularJS and scope.$apply
- execution context and scope
- Function Inheritance and Overriding and Function Overloading In D
- python namespace and variable scope
- Android Activity Lifecycle(Finish)
- 双缓冲
- 多业务安全路由器网关走俏的原因
- 生成一定范围的随机数
- 爱立信笔试
- OverLoading and Scope
- getRecentTasks过程
- C与C++在Linux下的集成问题
- qsort函数简介
- hadoop管理NameNode AND SecondaryNameNode
- Linux下的段错误产生的原因及调试方法
- JavaScript 确认框 confirm
- Android 左右滑动切换页面或Activity的效果实现
- HTML5之CANVAS 用法示例汇总