指向函数的指针声明和指向数组的指针声明容易混淆,原因在于函数和数组修饰符的优先级比指针修饰符的优先级高,因此通常需要使用圆括号. int *f1( );//一个返回值为 int* 的函数 int ( *f2 )( );//一个指针,指向一个返回值为 int 的函数 具有高优先级的数组修饰符存在同样的问题: const int N = 12; int *a1[ N ];//一个具有N个大小的数组,每个元素是 int * int ( *ap1 ) [ N ];//一个指针,指向一个具有N个 int…
使用char数组,进行字符串的操作,是c风格的操作方式. string是C++的风格,感觉string本质上就是一个vector<char> 以下代码详细展示了字符串的常见操作 #include <iostream> #include <string> // make string class available //#include <cstring> // C-style string library int main() { using namespa…