
C/C++
striverpan
这个作者很懒,什么都没留下…
展开
-
C++文件IO
经过原创 2014-10-30 17:19:17 · 465 阅读 · 0 评论 -
std::vector的几种遍历方式比较
std::vector是我在标准库中实用最频繁的容器。总结一下在遍历和创建vector时需要注意的一些地方。 在不考虑线程安全问题的前提下,在C++11中有五种遍历方式。方式一for (size_t i =0; i size(); i ++) { int d = vec[i]; } 方式二转载 2015-06-20 13:10:24 · 1264 阅读 · 0 评论 -
队列 火车调度
//============================================================================// Name : C++Study.cpp// Author : pan// Version :// Copyright : Your copyright notice// Descri原创 2015-07-04 17:05:01 · 1024 阅读 · 0 评论 -
C积累
不可以修改指针字符串har *m = "hello";"hello"保存在静态数据区,该数据不能修改.由指针m指向. 不能通过指针m来修改静态数据区的值.char w[] = "hello";"hello"保存在栈空间数组里. 数组名为w, 函数名为数组的首地址.可以通过w[i]='a', 或*(w+i)='a'的形式来修改数组内容.坑爹 倒置字符串。。原创 2015-06-13 21:30:47 · 430 阅读 · 0 评论 -
c++模板
#include using namespace std;templateT fun1(T a){ return a;}int main(){ int a=fun1(2); cout return 0;}一般用typename 不用class 区别类定义原创 2015-07-27 16:33:14 · 297 阅读 · 0 评论 -
C++引用
#include #include using namespace std;void rchange(int& a,int& b){ int temp; temp=a; a=b; b=temp;}int main(){ int a=0,b=1; rchange(a,b); cout原创 2015-07-27 20:50:57 · 337 阅读 · 0 评论 -
C++ 模板类
//头文件#ifndef PERSON_H#define PERSON_Htemplate class Person{public: Person(); virtual ~Person(); T fun1(T a); void fun2(T a);protected:private:};#endif // PE原创 2015-07-27 19:21:49 · 369 阅读 · 0 评论 -
C++文件操作
ifstream fis("ReadMe.txt"); if(fis.fail()){exit(1);}ofstream fos("test2.txt");string s;while( getline(fis,s) ) { cout fosfos }fis.close();fos.close();原创 2015-08-08 20:29:24 · 355 阅读 · 0 评论 -
C++静态成员与函数
头文件:Person.h#includeusing namespace std;#pragma onceclass Person{private:string name;string age;static int count1;//static类变量public:const string getAge();void setAg原创 2015-07-29 16:03:57 · 371 阅读 · 0 评论