
C++学习
mikewolf2009
这个作者很懒,什么都没留下…
展开
-
c++中使用变长参数列表
C++是C的超集,但C中的几个隐含特性C++中却找不到对应的“替代品”,... c++以及c中函数传递参数时(按值传递),参数从左到右入栈,看下面的代码:#include "stdafx.h"#include using namespace std;void fun(int a, ...){ int *temp= &a; int i;原创 2009-09-10 19:07:00 · 1280 阅读 · 0 评论 -
c++中头文件
在c++中要防止头文件循环包含和多重包含,这就需要定义定义头文件时,加上 #ifndef _XXX_H#define _XXX_H....#endif 另外还有一种forward reference. 如果要引用一个类,但不能包含其头文件(比如,该类依赖于你正在编写的类),可以简单的告诉编译器存在该类就可以了,比如与引用原创 2009-09-10 20:13:00 · 599 阅读 · 0 评论 -
字符串替换函数
字符串替换函数:#include "stdafx.h"#include #include using namespace std; string replaceAll(string s1, string s2, string s3){ string str1(s1); string::size_type st = str1.find(s2);原创 2009-09-19 10:05:00 · 515 阅读 · 0 评论 -
优先队列的用法
#include "stdafx.h" #include #include #include using namespace std; //看看priority_queue的声明,模板的第三个参数就是比较规则,规则可以是个函数,也可是个仿函数 //template , // class Compare =原创 2009-09-20 11:16:00 · 715 阅读 · 0 评论 -
c++类型转化的比较
== ============================================= dynamic_cast .vs. static_cast == ===========================================class B { ... }; class D : public B { ... }; void f(B* pb) {原创 2009-10-20 21:19:00 · 634 阅读 · 0 评论 -
c++中类型转化
C 风格(C-style)强制转型如下: (T) exdivssion // 把exdivssion转化为T类型比如: int a = (int)3.2; 函数风格(Function-style)强制转型使用这样的语法: T(exdivssion) // cast exdivssion to be of type T 这两种形式之间没有本质上的不同,它纯粹就是一原创 2009-10-20 20:59:00 · 530 阅读 · 0 评论