Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Difference between “::” “.” and “->” in c++ ====== * - > for accessing object member variables and methods via pointer to object <code cpp> Foo *foo = new Foo(); foo->member_var = 10; foo->member_func(); </code> * . for accessing object member variables and methods via object instance <code cpp> Foo foo; foo.member_var = 10; foo.member_func(); </code> * :: for accessing static variables and methods of a class/struct or namespace. It can also be used to access variables and functions from another scope (actually class, struct, namespace are scopes in that case) <code cpp> int some_val = Foo::static_var; Foo::static_method(); int max_int = std::numeric_limits<int>::max(); </code> development/cpp/differences.txt Last modified: 2019/10/31 09:04by 127.0.0.1