When do you write "->", "." and "::" respectively?

Asked 2 years ago, Updated 2 years ago, 33 views

C++ is related to the class

We can use it together. In what circumstances are those three used?

c++

2022-09-22 22:25

1 Answers

:, ., -> operators are double colon, dot, and arrow, respectively Used to access a class member or class object in C++.

Each of the three has a different situation. If you look at the code

Write when b is a member of the class/namespace a. In this case, a is the name of the class or namespace

Used only when b is a member of object a. In this case, a is the object of the class.

Usually (*)a.stands for b. However, -> can be overloaded, so in this case, it behaves as defined by the person who implemented it.


2022-09-22 22:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.