03 2011 档案

摘要:我们定义如下类: //A.hclassA{private:staticconstintm=5;staticintn;staticvectorbuf;};其中包含三个私有的静态类成员,C++规定const静态类成员可以直接初始化,其他非const的静态类成员需要在类声明以外初始化,我们一般选择在类的实现文件中初始化,初始化的方式是书写一遍类型的定义://A.cppintA::n; //不指定任何初始值,系统自动初始化为0vectorA::buf; //调用vector的默认构造函数来初始化 //注意:调用默认构造函数时,不要使用括号,否则编译器将把A... 阅读全文
posted @ 2011-03-25 09:30 fre2technic 阅读(38995) 评论(2) 推荐(6)
摘要:这两个头文件都在linux的/usr/include目录下面,后者比前者多了一个s,一般使用以string.h(没有s)的为主,那strings.h(有s)什么时候使用呢?打开这个头文件,可以看见区别如下:/* We don't need and should not read this file if <string.h> was already read. The one exception being that if __USE_BSD isn't defined, then these aren't defined in string.h, so w 阅读全文
posted @ 2011-03-15 18:30 fre2technic 阅读(2395) 评论(0) 推荐(0)
摘要:pthread_create()是linux上,创建新线程的调用,按照info给出的例子使用,编译时,会出现这个错误提示。这实际是一个链接错误。原因是,该函数实现在libpthread.so或者libpthread_nonshare.a中(在64 bitOS上,这两个库在/usr/lib64目录中),但是这两个库都不是linux的默认库,编译时,需要加上-lpthread参数。例如: g++ xxx.c -o xxx -lpthread如果使用了类似eclipse之类的IDE工具,可以在项目属性中设置。 阅读全文
posted @ 2011-03-04 15:47 fre2technic 阅读(379) 评论(0) 推荐(0)
摘要:man就是manual的缩写,用来查看Linux系统中自带的各种参考手册,手册页分为几个部分,如下:1 Executable programs or shell commands2 System calls (functions provided by the kernel)3 Library calls (functions within program libraries)4 Special files (usually found in /dev)5 File formats and conventions eg /etc/passwd6 Games7 Miscellaneous (in 阅读全文
posted @ 2011-03-01 17:02 fre2technic 阅读(302) 评论(0) 推荐(0)