web analytics

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

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 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

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

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

Is it possible to pass an object from one function to another ─ justify from an example.

Passing Objects:An object can be used as a function argument in the following two ways, pass-by-value pass-by-reference Using the first option given above we pass the value of an object to a function where the value of the used object will not change, but only be used. Use of the second will change the object … Read more

What is meant by the statement #include?

#include<iostream>:This is a directive which causes the preprocessor to add the contents of iostream, which is a header file and must be added above all of a program where input/output statements has been used. We will include the header file with the statement                                                           #include <iostream> The iostream package automatically defines a variable (an … Read more