ptr->hello(); /* VERSUS */ (*ptr).hello();

前端 未结 6 1010
无人及你
无人及你 2020-12-02 01:41

I was learning about C++ pointers and the -> operator seemed strange to me. Instead of ptr->hello(); one could write (*ptr).hello();

6条回答
  •  时光说笑
    2020-12-02 02:32

    These alternate syntax modes are adopted from C, and you might get some additional understanding from A Tutorial on Pointers and Arrays in C, specifically, chapter 5, Pointers and Structure.

提交回复
热议问题