Effective c++ 3/e item 15 疑問解惑
来源:互联网 发布:河南省进出口数据 编辑:程序博客网 时间:2024/06/05 23:34
轉載自http://stackoverflow.com/questions/4728160/thrown-off-by-functor-syntax-in-effective-c
The first
operator FontHandle() const {return f;}
The second
FontHandle operator()() const {return f;}
The first, operator FontHandle
, is a conversion operator. It allows an instance of this class type to be implicitly converted to a FontHandle
object, so you could write:
Font myFont;FontHandle handle = myFont;
More commonly, conversion operators are used to allow you to use an object of one type as if it were another type in an expression. For example,
void f(FontHandle fh);Font myFont;f(myFont); // converts myFont to a FontHandle via the conversion operator
The second, operator()
, is an overload of the function call operator. It allows an instance of your class type to be used as if it were a function taking no arguments:
Font myFont;myFont();
0 0
- Effective c++ 3/e item 15 疑問解惑
- Effective Modern C++》Item 3总结
- Effective-Objective-C-读书笔记-Item-3
- Effective Modern C++: Item 3 ->弄清decltype
- More Effective C++:Item 27
- More Effective C++:Item 27
- <Effective C++> (Item 13-15): 以对象管理资源
- Effective C++----3rd Edition, Item 3:尽可能使用const
- <Effective Mordern C++>笔记:Item 3:Understand decltype .
- Effective Modern C++ Item 3
- read Item 25 of《More Effective C++》
- 《Effective Modern C++》Item 1总结
- 《Effective Modern C++》Item 2总结
- Effective-Objective-C-读书笔记-Item-1
- Effective-Objective-C-读书笔记-Item-2
- <Effective Mordern C++>Item 6:UseTheExplicitlyTypedInitializerIdiomWhenAutoDeducesUndesiredTypes
- 《Effective C#》Item 15:利用using和try-finally来释放资源
- Effective Objective-C 2.0:Item 15: Use Prefix Names to Avoid Namespace Clashes
- 换主页轮播的主题图片(2、添加)---轻开电子商务系统(企业入门级B2C网站)
- HDU1052Tian Ji -- The Horse Racing(贪心)
- PB 数据窗口打印详细控制代码
- codeforces #307 C. GukiZ hates Boxes(贪心+二分)
- java笔记27 编码表与编码转换
- Effective c++ 3/e item 15 疑問解惑
- codeforces #307 B. ZgukistringZ(枚举+计数)
- Win10预发行版5个密钥曝光!激活就靠它
- cacti安装记录 第一阶段 LAMP源码环境配置 复盘
- 通过luarocks贡献代码
- Permutation 各种变种
- leetcode-100-Same Tree
- ipad 连接 win8 总是出现 信任此电脑
- 浅谈用 源码包,rpm包安装软件的区别、相同结果的实现与pkg-congfig的关系 (研究总结)