self-confidence,the source of all the power

导航

2014年11月4日 #

C++ 模板的用法

摘要: C++中的高阶手法就会用到泛型编程,主要有函数模板, 在程序中使用模板的好处就是在定义时不需要指定具体的参数类型,而在使用时确可以匹配其它任意类型, 定义格式如下template T func(T ...) {}让我们来看一个简单例子,写一个swap()将两个整数交换位置,void swap(int... 阅读全文

posted @ 2014-11-04 23:57 漩涡鸣人 阅读(549) 评论(0) 推荐(0) 编辑

C++ 文件操作

摘要: 用于文件操作主要有两个类ifstream,ofstream,fstream,例子如下1. 读操作#include using name space std;int main(){ cCar car; // initialize a car object ifstream... 阅读全文

posted @ 2014-11-04 23:01 漩涡鸣人 阅读(784) 评论(0) 推荐(0) 编辑