adspace
What is Advantage and Use of THIS pointer in C++ – Scenarios?
Answer Posted / Atul Kumar Tripathi
"The 'this' pointer in C++ serves multiple purposes:
1. Accessing member variables: Within a non-static member function, 'this' can be used to access the object's instance variables.
2. Dot (.) operator override: In some cases, you may want to override the dot (.) operator for better readability or specific functionality. The 'this' pointer is useful in such scenarios.
3. Invoking other member functions: You can use 'this' pointer to call other member functions of the same class.
4. Dynamically calling constructors: In a derived class, you can use 'this' pointer to call constructors of the base class.
5. Scope resolution operator (::) override: You can use 'this' pointer along with the scope resolution operator to avoid ambiguities in function overloading and namespace conflicts."n
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
What character terminates all character array strings a) b) . c) END
sir please send me bpcl previous question papers
Can union be self referenced?
What is the latest version on c++?
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
daily Routine of father
Please send ford technologies placement paper 2 my mail id
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?