
C++
文章平均质量分 79
eijnew
这个作者很懒,什么都没留下…
展开
-
Linux多线程函数解析
Linux多线程函数解析Linux多线程函数用得比较多的是下面的3个pthread_create(),pthread_exit(),pthread_join();它们都是在头文件之中。编译时需要加静态库-lpthread 下面是函数的说明: pthread_create是UNIX环境创建线程函数 int pthread_create( pthread_t *转载 2011-12-29 13:57:14 · 892 阅读 · 0 评论 -
Why C++ Supports both Class and Typename for Type Parameters
Recently, someone asked me why we support both class and typename within C++ to indicate a type parameter since the keywords do not hold any platform significance – for example, class is not meant to转载 2012-03-21 14:50:05 · 1642 阅读 · 0 评论 -
C++中POD是什么?
什么是POD? POD 的全称是 Plain Old Data,在C++标准中,POD是这样定义的: Arithmetic types (3.9.1), enumeration types, pointer types, and pointer to member types (3.9.2), and cv-qualified(注2) versions of these types (3.原创 2012-03-19 15:41:54 · 10028 阅读 · 0 评论 -
char **和char *[M]有什么区别?
原文链接在此在函数参数中,extern int func(char **);和extern int func(char *[M]);是代表不同含义的。前者表示函数期望一个指针,该指针指向一块内存,该内存中包含N个指针,每个指针指向一块内存;这些指针指向的内存可能是连续的,也可能不连续,长度并且不一定相同;其中&a[0][0]和&[1][0]无翻译 2012-03-05 15:31:03 · 4458 阅读 · 0 评论 -
为什么不能使用成员变量的值作为成员函数的默认参数?
在解决工作中遇到一个问题时,我定义了一个类c(如下所示),包含两个功能类似的公共查询接口Rate()和Rate(char bs_flag, char sh_flag),二者的区别是,在实例化对象的时候,会包含bs_flag和sh_flag,因此我希望有一个不用指定查询条件的Rate函数,用来反映默认情形;但有时又需要变更查询条件查询,如第二个指定查询条件的Rate函数,那么能否将这两个函数合并呢?原创 2012-03-01 17:00:14 · 4737 阅读 · 0 评论 -
在operator=或拷贝构造中对所有数据成员赋值
1. operator=赋值操作符Effective C++条款16中描述到,在派生类中重写赋值操作符函数时,要注意不要忘记对基类对象部分也要赋值,而这一点恐怕是许多新手容易忘记的,他们很自然地不会想到这一点(例如我),比如下述代码:class CBase{public: CBase& operator=(const CBase& another) {原创 2012-02-29 16:11:57 · 1792 阅读 · 0 评论 -
C++异常处理 -- 异常对象(Exception Object)
在C++异常处理中,throw可以抛出任何对象,可以是int类型,也可以是class类型,对于catch块而言,有两种选择:1)catch这个类型,例:int main(){ int a=1; try { throw a; } catch(int) // 捕获int型异常,无法获知a的内容 { cout<原创 2012-02-28 15:34:22 · 4784 阅读 · 0 评论 -
使用const_cast转换全局const变量导致程序崩溃的原因
#include using namespace std;const int gc_var = 300;int main(){ const int lc_blah = 100; int &l_blah = const_cast(lc_blah); l_blah = 200; cout<<"l_blah: "<<l_blah<<endl; // Will原创 2011-12-29 12:28:26 · 2140 阅读 · 0 评论 -
升级到cocos2d-x 3.10之后被遗忘的ccui.PageView.pageTurningEvent()
升级到cocos2d-x 3.10之后被遗忘的ccui.PageView.pageTurningEvent()原创 2016-05-03 19:34:27 · 5435 阅读 · 1 评论