Archive for category Programming
C++学习笔记整理
最近一直在翻Windows核心编程,记笔记时发现以前看C++写的一些东西,决定好好整理下,当作复习。
指针和迭代器:
const_iterator是指向const的对象的迭代器,类似const ctype *ptr,无法通过它给所指的对象赋值。
注意:用iterator访问vector时,vector长度的改变可能使iterator失效; 把const的对象地址赋给一个非const的指针是非法的。
常量指针:
- ctype *const ptr = &val;
- // 下面是另一种用法:
- typedef string *pstring;
- const pstring cstr;
指向多维数组的指针的使用:
- int a[3][5];
- int (*p)[5] = a;
delete函数:
在释放指向数组的指针指向的内存时,不要遗漏方括号。这是内存泄漏的原因之一。
正确做法:delete [] arrayname;
Read the rest of this entry »









