What is Function Overloading in C++ ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Function overloading is the process of using the same name for two or more functions. However each function will be different in terms of either different types of parameters or a different number of parameters. It is only through these differences that the compiler knows which function to call in any given situation. Even if […]

Read the rest of this entry »

What are Pointers in C++ (Object Oriented Programming) ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Pointers are used to store memory address values of objects. C++ defines a special address-of operator that when applied to an object returns that object’s address value.
E.g. int *pint; //this defines a pointer variable
In order store the address of the variable ‘j’ into pint one should assign the address of j into pint variable as […]

Read the rest of this entry »

What is the Difference between Overloaded Functions and Overridden Functions ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

In C++, overloading is simply the use of the same function identifier for different functions declared in the same scope.
E.g.
void display (int);
void display (string);
The above two functions are clearly overloaded. The compiler will distinguish among them by the actual argument used in the call to display.
Overriding can occur only in the presence of a base […]

Read the rest of this entry »

What are Inline Functions ? When are Inline Functions used ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

The idea behind inline functions is to insert the code of a called function at the point where the function is called. It is useful to distinguish between “inline,” a keyword qualifier that is simply a request to the compiler, and “inlined,” which refers to actual inline expansion of the function.
A function can be decorated […]

Read the rest of this entry »

What is ‘this’ Pointer (object) in C++

October 28, 2007 · Filed Under C++ Questions, Placement Questions

When a member function is called, it is automatically passed an implicit argument that is a pointer to the invoking object (that is, the object on which the function is called).This pointer is called this.
Within a member function, the members of a class can be accessed directly, without
any object or class qualification. The this pointer […]

Read the rest of this entry »

What is Scope Resolution Operator in C++?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

There are two used of the scope resolution operator in C++.
The first use being that a scope resolution operator is used to unhide the global variable that might have got hidden by the local variables. Hence in order to access the hidden global variable one needs to prefix the variable name with the scope resolution […]

Read the rest of this entry »

What are the Storage Types for Variables in C++ ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

There are four different storage types for variables:
- Auto: An auto variable is a local scope variable whose lifetime contained within a function definition (or function block). All local variables are by default auto variables. These variables persist only until the end of the block in which they are defined.
- […]

Read the rest of this entry »

Explain Composition in C++ with an example

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Composition allows software to be developed by assembling existing components rather than creating new ones. Composition is also sometimes called as aggregation and defines the process of putting an object inside another object. It models the has-a relationship. E.g. a class employee can contain an object of type salary which itself is another type of […]

Read the rest of this entry »

What are static Data and Static Member Functions in C++ ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Static data members are data and functions that are associated with the class itself, rather than with the objects of the class. For example a count is needed of how many objects of a particular class type have been created at any one point in the program.
A static data member acts as a global object […]

Read the rest of this entry »

What is a Pure Virtual Member Function ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Whenever a virtual function in a base class is not redefined by the derived class then the version defined in the base class will be used. However in many cases it may so happen that there can be no meaningful definition of a virtual function within the base class. Or you may want to ensure […]

Read the rest of this entry »