DEV Community

qiumingming7@gmail.com
qiumingming7@gmail.com

Posted on

Answer: What is the difference between “::” “.” and “->” in c++ [duplicate]

1.-> for accessing object member variables and methods via pointer to object

Foo *foo = new Foo();
foo->member_var = 10;
foo->member_func();

2.. for accessing object member variables and methods via object instance

Foo foo;
foo.member_var = 10;
foo.member_func();

3.:: for accessing static variables and methods of a…

Top comments (0)