Effective STL 6 Vexing parse
来源:互联网 发布:云计算优点图片 编辑:程序博客网 时间:2024/06/08 13:54
I. Warm up
int f(double (d)); // same as int f(double d);
int g(double (*pf)()); // g takes a pointer to a function as a parameter
int g(double pf()); // same as above; pf is implicitly a pointer
int g(double()); // same as above; parameter name is omitted
II. vexing parse
the function data takes two parameters
list<int>data(istream_iterator<int>(dataFile), istream_iterator<int>());
the proper way to declare data
list<int>data((istream_iterator<int>(dataFile)), istream_iterator<int>());
Note: It is not legal to surround a formal parameter declaration with parentheses, but it is legal to surround an argument to a function call with parentheses.
III. A better solution
ifstream dataFile("inst.dat");istream_iterator<int>dataBegin(dataFile);istream_iterator<int>dataEnd;list<int>data(dataBegin, dataEnd);
阅读全文
0 0
- Effective STL 6 Vexing parse
- Effective STL Item 6: Be alert for C++’s most vexing parse.
- [C++] Most Vexing Parse
- cpp's most vexing parse
- C++'s most vexing parse
- C++'s most vexing parse
- Item 6. Be alert for C++'s most vexing parse.
- Effective STL 读书笔记 6
- Effective STL 条款6
- effective stl item 6
- Effective stl 第6条
- Effective STL
- Effective STL
- Effective STL
- Effective stl
- Effective STL
- Effective STL
- Effective STL
- ajax的简略用法与Json格式
- 第六章: 自定义函数
- Qt之深入理解gesture
- 爬虫实战之二--mongodb及redis安装
- Openfire分析之一:Openfire与XMPP协议
- Effective STL 6 Vexing parse
- js符号 "+" 运算
- 策略迭代与值迭代的区别
- mysql的EXPLAIN关键字输出结果解释
- 具有双击或者右击关闭标签页功能的chrome扩展程序汇总
- DotSpatial学习之路一——简介及基本操作
- Neural Networks and Deep Learning系列(一)概述
- QPinchGesture QGesture 使用方法
- 第2章 基础特性