c++用模板重写<<方法
2017-09-16 00:00
274 查看
摘要: c++用模板重写<<方法
#include <iostream> #include <string> #include <vector> template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { for (auto& el : vec) { os << el << ' '; } return os; } int main() { std::vector<std::string> words = { "Hello", "from", "GCC", __VERSION__, "!" }; std::cout << words << std::endl; }
相关文章推荐
- 设计模式C++实现(5)——原型模式、模板方法模式
- 设计模式C++学习笔记之九(Template Method模板方法模式)
- [C++设计模式]template 模板方法模式
- C++实现模板顺序表和三种排序方法
- java 模板方法模式 <设计模式>
- C++设计模式--模板方法模式
- 设计模式C++实现(5)——原型模式、模板方法模式
- C++模板常用使用方法介绍
- 设计模式之模板方法模式,C++实现
- eclipse develop for C\C++ 文件注释函数注释代码模板自动生成方法
- [C++设计模式]template 模板方法模式
- 行为模式之模板方法模式(Template Pattern)C++实现
- 《大话设计模式》--考题抄错会做也白搭--模板方法模式<TemplateMethod>(10)
- c++调用java时得到java签名的方法javap -s -p <classname>
- 设计模式C++实现(5)——原型模式、模板方法模式
- C++头文件中<>与""的区别,实例化类的两种方法
- C++ 模板方法
- C++重载操作符+, - , *, <<的方法
- JNI方法调用C++类库 <二>
- c++ 模板参数做容器参数迭代器报错 vector<T>::const_iterator,typename const报错