09 2016 档案

摘要:基础议题1 当你知道你必须指向一个对象并且不想改变其指向时,或者在 重载操作符并为防止不必要的语义误解时,你不应该使用指针。 1 必须指向对象,不能引用空 2 始终指向相同的内存块 3 避免 *v[5]=102 static_cast<double>(var) 同c类型的转换 const_cast 阅读全文
posted @ 2016-09-30 16:16 navas 阅读(215) 评论(0) 推荐(0)
摘要:$@ : 参数本身的列表,不包括命令本身 $* : 和$@相同,但"$*" 和 "$@"(加引号)并不同,"$*"将所有的参数解释成一个字符串,而"$@"是一个参数数组 摘抄一个: https://blog.linuxeye.com/389.html 阅读全文
posted @ 2016-09-26 15:21 navas 阅读(133) 评论(0) 推荐(0)
摘要:1 #include 2 3 using namespace std; 4 5 class father 6 { 7 public: 8 father(int x):m_idata(x) 9 {} 10 11 virtual void show(int idata) 12 { 13 cout << "papa" <... 阅读全文
posted @ 2016-09-19 11:10 navas 阅读(327) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2016-09-18 15:38 navas 阅读(160) 评论(0) 推荐(0)
摘要:fork - create a child process#include <unistd.h>pid_t fork(void); exec系列。 int pthread_create(pthread_t *restrict tidp,const pthread_attr_t *restrict_a 阅读全文
posted @ 2016-09-17 20:44 navas 阅读(135) 评论(0) 推荐(0)
摘要:如果发出信号(pthread_cond_signal, pthread_cond_broadcast)时,没有线程在条件变量的wait 中等待,则这个信号丢失,其他线程走到wait时,投入睡眠状态。 对于本例子中,假设各线程必须要接收该信号(线程还没走到等待,主线程已经发送信号造成丢失),那么 应该 阅读全文
posted @ 2016-09-17 20:12 navas 阅读(1023) 评论(0) 推荐(0)
摘要:pthread_cond_wait时,需要传入条件变量和互斥变量,并且外围需要锁住和释放互斥锁。因为我们等待时判断的变量往往就是引起冲突的共享变量。 阅读全文
posted @ 2016-09-17 19:45 navas 阅读(171) 评论(0) 推荐(0)
摘要://pthread_key_create 使用&key pthread_setspecific pthread_getspecific 直接使用key(作为pkey的索引)//同一个key只能create一次(进程内),否则报22错误,invalid argument//pthread_once & 阅读全文
posted @ 2016-09-16 20:54 navas 阅读(318) 评论(0) 推荐(0)
摘要:1 #include 2 using namespace std; 3 4 void show() throw (int) 5 { 6 throw double(2); 7 } 8 9 int main() 10 { 11 try{ 12 show(); 13 } 14 catch (double eobj) 15 ... 阅读全文
posted @ 2016-09-15 17:34 navas 阅读(129) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2016-09-15 17:10 navas 阅读(97) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2016-09-15 17:08 navas 阅读(116) 评论(0) 推荐(0)
摘要:三者用法相似,enum限定了取值范围,union更多作用应该是在以void*类型拷贝数据后,按内部类型做具体解析。 阅读全文
posted @ 2016-09-14 22:13 navas 阅读(194) 评论(0) 推荐(0)
摘要:1 #include 21 #define KKK 22 #define TT 23 24 #pragma pack(2) //define to 2 25 struct test_t 26 { 27 int a; 28 char b; 29 short c; 30 char d; 31 }; 32 #pragma pack() ... 阅读全文
posted @ 2016-09-14 20:28 navas 阅读(244) 评论(0) 推荐(0)
摘要:1 char pp[100]; 2 char *kl = pp; 3 strcpy(kl,"23456"); 4 kl += 7; 5 strcpy(kl,"abcde"); //this will not show,because 0 is before them 6 cout << pp << "33" << endl; 7 ... 阅读全文
posted @ 2016-09-14 20:19 navas 阅读(974) 评论(0) 推荐(0)
摘要:1 #include 2 using namespace std; 3 4 class Base 5 { 6 public: 7 Base( void ) 8 { 9 cout kkk(); //child 60 61 Base &ba = *pD; 62 ba... 阅读全文
posted @ 2016-09-14 20:17 navas 阅读(346) 评论(0) 推荐(0)
摘要:1 #include 2 3 int main() 4 { 5 6 int isw = 0; 7 switch(isw) { 8 9 case 1: //just lables 10 int a = 0; //a在这里定义,有效期到switch的},如果直接走了case2,... 阅读全文
posted @ 2016-09-14 20:10 navas 阅读(420) 评论(0) 推荐(0)