In c++ is there any difference between these 3 blocks of code:
MyClass->m_Integer // 1
MyClass::m_Integer // 2
MyClass.m_Integer // 3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
->and.operators are way to access members of an instance of a class, and::allows you to access static members of a class.The difference between
->and.is that the arrow is for access through pointers to instances, where the dot is for access to values (non-pointers).For example, let’s say you have a class
MyClassdefined as:You would use those operators in the following situations:
In Java, this would look like: