c++ typedef的一些理解

c++ typedef的一些理解

最近在看c++primer,在看到6.7章函数指针对typedef用法有些疑问,上半部分基本清楚了,下半部分还是有些疑问。
在书里将typedef的章节部分没有提及这种使用方法,不知道我加的注释是否正确,如果有清楚的欢迎留言,不胜感激!

char a = 'a';
 const char b = 'b';
 typedef char * pstring;
 const pstring cstr = &a; //顶层const 相当于char * const pev,与const char * p 不同 //不能直接带入理解
 const char * p = &b;     //底层const
 char * const pev = &a;  //顶层const

/////////////////////////////////////////////////

//正常声明函数指针的方法是:
//eg:
int (*pf)(int a, int b) ;
//使用typedef可以直接将pf这个函数指针转化为函数指针类型
typedef int(*pf)(int a, int b);
 vector<pf> v;

猜你喜欢

转载自blog.csdn.net/TinnCHEN/article/details/86562712