In C++, class member functions deal with primarily two types of variables – member variables and input variables. We don’t need to take special care in accessing them. C++ has a requirement that all member variables will have unique names. Similarly, all input variables will have unique names also. But an input variable of a … Continue reading “Variable Name Ambiguity in Class Member Function”
Category: C++
Backpointer – Concept and Application
We often work with data structures with connected nodes – like trees and graphs. In a tree, the parent nodes generally hold the pointers of their child nodes. But the child nodes can also hold the pointer back to their parent. Developers often refer this type of pointers as backpointers. In this diagram, the black … Continue reading “Backpointer – Concept and Application”
The ‘this’ Pointer Usage in C++
We discussed about the concept of this pointer in this article. The C++ compiler internally manages it. In general, we don’t need to worry about it. But there are scenarios where we need to use it explicitly. Resolving Ambiguity between Member and Input Variables A member function of a class deals with two types of … Continue reading “The ‘this’ Pointer Usage in C++”
The this Pointer in C++
In C++, the this pointer is generally used in the non-static member functions of a class. It refers to the address of the object the function is accessed through. Let’s understand the concept. C++ classes have mainly two types of components – properties (data) and functions. Every object, created from a class, will have a … Continue reading “The this Pointer in C++”
Static Members of a C++ Class
The class members are by default non-static. That means we can access them in the context of an object only. Each object will have its own copy of the data members. Even though the code segment is common for all objects of a class, the member functions can be called in the context of an … Continue reading “Static Members of a C++ Class”