摘要: char *screenInit(int height, int width, char background = ' ');char *screenInit(int height = 4, int width = 4, char background);正确;char *screenInit(int height, int width, char background = ' ');char *screenInit(int height = 4, int width = 4, char background = ' ');//redefinit 阅读全文
posted @ 2011-07-23 22:23 lidan 阅读(260) 评论(0) 推荐(0) 编辑
摘要: int a[][];错误,多维数组的规则是 只有最后一维的大小能省略, 可以定义为int a[][5];int (*pa)[];不好,应该int (*pa)[size];声明可以, 但是赋值的时候就会有错误,例如:int a[] = {1, 2, 3};pa = &a;//cannot convert parameter 1 from 'int (*)[3]' to 'int (*)[]'所以定义指向数组的指针的时候最好把数组的大小确定; 阅读全文
posted @ 2011-07-23 21:38 lidan 阅读(144) 评论(0) 推荐(0) 编辑
摘要: const 引用:1. int i = 20; const int& refer = i; i = 12;可以, refer的值会变, 但是不能给refer赋值2 int i = 20; int* &rval = &i;错误, a refrence is not to const cannot be bound to a non-lvalue 因为&i不是一个左值, 所以ral必须声明为const型的 int* const &rval = &i;数组的引用: int ia[10]; int (&iaref)[10] = ia;这样就得到了 阅读全文
posted @ 2011-07-23 11:54 lidan 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 指向数组的指针:int(*p)[5];定义了一个指向数组元素为int型的元素个数为5的一维数组;也可以理解为二维数组的首元素就像int*p指向int型可以理解为一维数组的首元素;也可以理解为*p为一个指针,指针里面的内容是一个有5个int值的数组;*p=a[5];其中,"类型说明符"为所指数组的数据类型。"*"表示其后的变量是指针类型。"长度"表示二维数组分解为多个一维数组时,一维数组的长度,也就是二维数组的列数。注意,"*(指针变量名)"两边的括号不可少,如缺少括号则表示的是指针数组。p指向二维数组的第一个元素a 阅读全文
posted @ 2011-07-23 11:23 lidan 阅读(399) 评论(0) 推荐(0) 编辑