ptr->a()和 (*ptr).a()有何不同

标准中对于类成员访问有如下说明:

3 If E1 has the type “pointer to class X,” then the expression E1->E2 is converted to the equivalent form (*(E1)).E2;

即对于指向class X类型的指针,E1->E2会被转化成等价的形式(*(E1)).E2,那么对于编译器而言会产生相同的代码,对于机器而言就没有什么差别了。

posted @ 2011-04-21 01:48  BiG5  阅读(163)  评论(0编辑  收藏  举报