web analytics

What is namespace?

Namespace: Namespace defines a scope for the identifiers that are used in the program. To use we will do the following      using namespace namespace_name; here, at namespace_name we will give the name of the namespace we want to use. Supposing that we are writing the following,      using namespace std; here, std is the … Read more

What is function overloading? Discuss this.

Function Overloading: Overloading refers to the use of the same thing for different purposes. When the same name for different functions is used that is called function overloading. The functions are then distinguished by their parameters or argument lists. Functions can be overloaded by changing, increasing or decreasing their arguments, float add(float a, float b)int … Read more

What is constructor?

Constructor:A constructor is a ‘special’ function whose task is to initialize the objects of its class. It is special because its name is the same as the class name. A constructor is executed whenever object of its class is created. It is called constructor because it constructs the values of data members of the class. … Read more

Write some properties of constructor?

Properties of Constructor Function: Following are some properties of Constructor Function They will have the same name as of their class. They should be declared in the public section. They are executed automatically when objects are created. They do not have return types, not even void and thus they can’t return values. They can’t be … Read more

How does a static member variable or static data member differs from a non-static variable or data? Explain with an example.

Static Data Member and Difference with Non-static Data Member: In general when we declare some objects of a class, each object is allocated with memory space for each variable of the class separately under them as given below, But in the case of static data member only one memory location will be allocated and that … Read more

Write down some properties of static member function.

Properties of Static Member Function: Following are some properties of Static Member Function A static member function can only have access to other static data members and functions declared in the same class. A static member function can be called using the class name with a scope resolution operator instead of object name. Global functions and … Read more

Is it possible to return an object from a function? Justify your answer with an example.

Return of an Object from a Function: Yes it is possible to return an object from a function. An object can be returned to the call of its function by another object. For the justification considering the following program, //Returning of object#include<iostream.h>class myclass{ int i; public: void set_i(int n){ i=n; /*Ln 3*/ } int get_i(){ … Read more