1. Define Template.
template in C++
allows the construction
of a family
functions and classes to perform the
same operation on different data types. The template
type arguments are called “generic
2. Define function template.
The templates declared for functions
are called function templates. A function
template is prefixed with a keyword
template and list of template type arguments.
3. What is the syntax used for writing
template <class T>,……….>
class name function name(arguments)
Body of template function
4. Define class template.
The templates declared for classes are
called class templates. Classes can also be
declared to operate on different data
types. A class template specifies how individual
classes can be constructed similar to
normal class specification.
5. What is the syntax used for writing class
template < class T1, class T2, ……. >
class class name
// data items of template type T1,
// functions of template arguments T1,
6. Define exception handling process.
The error handling mechanism of C++ is
generally referred to as an exception
handling. It provides a mechanism for
adding error handling mechanism in a program.
7. What are the two types of an exception?
There are two types of an exception.
* Asynchronous exception.
8. How many blocks contained in an exception
three blocks contained in an exception handling process.
The keyword throw is used to raise an exception when an error is
generated in the computation. The throw expression initializes a temporary
object of the type T used in throw.
T // named object, nameless object or by
Define catch construct.
The exception handler is indicated by the keyword
catch. It must be used immediately after the statements marked by the keyword
try. Each catch handler will evaluate an exception that matches to the
specified type in the argument list.
// named object or nameless object
for handling an exception
Define try construct.
Try keyword defines a boundary within which an exception can occur. The
try keyword is a block of code enclosed by braces. This indicates that the
program is prepared to test for the exceptions. If an exception occurs, the
program flow is interrupted.
raising an exception
for handling an exception
for handling an exception
What are the tasks performed by an error handling
the problem causing an exception(hit the exception)
that an error has occurred(throw the exception)
the error information(catch the exception)
correct actions(handle the exception)
Define exception specification.
It is possible to specify what kind of exception can be thrown by
functions, using a specific syntax. We can append the function definition
header with throw keyword and
type of expressions to be thrown in the parenthesis. It is known as exception
What are the two types of an exception
() function.Unexpected () function.
Define terminate () function.
Terminate () is the function which calls abort () function to exit the
program in the event of runtime error related to the exception.
Define unexpected () function.
If a function throws an exception which is not allowed, then a function
unexpected () is called which is used to call abort () function to exit the
program from its control. It is similar to Terminate () function.
Define multiple catch.
Using more than one catch sections for a single try block. At first
matching, catch block will get executed when an expression is thrown. If no
matching catch block is found, the exception is passed on one layer up in the
Define catch all exception.
It is possible for us to catch all types of exceptions in a single catch
section. We can use catch (…) (three dots as an argument) for representing
catch all exception.
Define An Exception.
Exceptions refer to unusual conditions or errors
occurred in a program. 20. Define synchronous exception.
This type of an exception occurs during the program execution due to
some fault in the input data or technique is known as synchronous exception.
Examples are errors such as out-of-range, overflow,
and underflow. 21. Define asynchronous exception.
The exceptions caused by events or faults that are unrelated to the
program. Examples are errors such as keyboard interrupts, hardware malfunctions
and disk failures.
Inheritance is the most important property of
object oriented programming. It is a mechanism of creating a new class from an
already defined class. The old class is referred to as base class. And the new
one is called derived class.
23. What are
the advantages of an inheritance?
is used for extending the functionality of an existing class.
* By using
this, we have multiple classes with some attributes common to them.
* We HAVE
to avoid problems between the common attributes.
* It is
used to model a real-world hierarchy in our program.
How to derive a derived class from the base class?
A Derived class is defined by specifying its
relationship with the base class in addition to its own class.
derivedclassname : visibilitymode
members of derivedclass };
is protected derivation?
In case of protected derivation, the protected
members of the baseclass become protected members of the derived class. The
public members of the base class also become the protected members of the
is declared as protected is accessible by the member functions within its.
Define multiple inheritance.
A single derived class is derived from more than one base classes is
called multiple inheritance.
derivedclassname : visibilitymode baseclass1, visibilitymode baseclass2
body of the derivedclass }
Define multipath inheritance or virtual baseclass.
This form of inheritance derives a new class by
multiple inheritance of baseclasses which are derived earlier from the
baseclass is known as multipath inheritance.
involves more than one form of inheritance namely multilevel, multiple and
What is Generic function? Or Define function
function defines a general set of operations that will be applied to
types data. The type of data that the function will operate upon is passed to
it as a parameter. Through a generic function, a single general procedure can
be applied to a wide range of data.
function is created using the keyword „template‟
<class T type>ret_type function name(arg list)
note : T
type is a place holder name for a data type used by the function.
Define generic classes?
generic classes, we can create a class that defines all the algorithms used
class. The actual type of data being manipulated will be specified as a
parameter when objects of that class are created