this, public, private, protected, getter function, setter function, getter function, RumbaughObject-oriented programming (OOP) introduces some new terminology that you should be familiar with and be able to use. Please review the following terms.
Person p;
Person p;p is a variable that is also an object.
static and non-static. A newer, language-independent, but not universal, nomenclature calls all variables declared in class scope member variables and divides them into instance and class variables.
static variable ≡ class variablestatic functions declared in a C++ class. While running, they are bound to an object through the this pointer and can access its features without additional notation. They can also access the private features of parameter objects instantiated from the same class (see the fraction class's arithmetic functions for an example).static member variables.static functions. These functions do not have a "this" pointer and cannot access non-static member variables.fraction(int n, in d) : numerator(n), denominator(d) {}
The example highlights the initializer list in light blue. The function body in this example is empty, but the body may contain statements when needed.static member functions. The this pointer stores the address of the object that calls and is bound to a member function, and function statements use it when they need to refer explicitly to that object. For example, if x is an instance of a class that defines a function named operation, then the statement:
x.operation();calls operation and passes the address of x as an implicit or "invisible" argument that is stored in this.
int get_height()
{
return height;
} |
int getHeight()
{
return height;
} |
void set_height(int h)
{
height = h;
} |
void setHeight(int h)
{
height = h;
} |