(->) arrow operator and (.) dot operator , class pointer

后端 未结 6 697
粉色の甜心
粉色の甜心 2021-01-31 21:55

In C++ we know that for a pointer of class we use (->) arrow operator to access the members of that class like here:

#include 
usi         


        
6条回答
  •  有刺的猬
    2021-01-31 22:27

    Because by using [] like p[3] you are already dereferencing the pointer to array + index shift. After that you have to use ".", since p[3] is an object, not a pointer.

提交回复
热议问题