Implementation Of Circular Array Based Queue - [C++]

Hello!!
I am not able get many points in the Queue portion why we are using the this-> here. front is the not pointer type then also arrow operator is user with the pointer type object or data .

Hello @sudhanshu8917,

The dot and arrow operator are both used in C++ to access the members of a class. They are just used in different scenarios.

  1. a.b is only used if b is a member of the object (or reference[1] to an object) a. So for a.b, a will always be an actual object (or a reference to an object) of a class.
  2. a->b is essentially a shorthand notation for (*a).b, ie, if a is a pointer to an object, then a->b is accessing the property b of the object that a points to.

So, we use -> arrow if the object of the class is itself a pointer variable irrespective of the data members.

Hope, this is clear now.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.