Chapter - 5: Classes in C++

If there are four objects used in a program how many this pointer would exist for these objects and why?


No matter how many the objects are, there always one this pointer. It will point to the object that accesses the class members, and when another object access the class,  it simply points to that object, without being created separated for the second object. Another reason is, that no two objects can call a member function at the same time.

© 2021 Garbage Valuegarbage value logo