+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

C++ Template Interview Questions and Answers

1
What are the syntax and semantics for a function template?

Templates is one of the features of C++. Using templates, C++ provides a support for generic programming.

We can define a template for a function that can help us create multiple versions for different data types.

A function template is similar to a class template and it syntax is as follows:
template
Return-type functionName (arguments of type T)
{
//Body of function with type T wherever appropriate
}

2
What is Class element in C++?

A class is a user defined data type. It serves as a template of the objects. You can define structure and behavior of an object using class. It includes data and the member functions that operate on data.

3
How is static data member similar to a global variable?

The life of a static data member exists between the functions which means that they are resident through out the execution of a program like the global variables.

4
What is Inheritance in C++?

Inheritance enables a new class to reuse the state and behavior of old class. The new class inherits properties and methods from the old class and is called as derived class and the old class is called as base class. The methods thus inherited can be extended using overriding facility of C++.

5
Differentiate between a template class and class template.

Template class: A class that has generic definition or a class with parameters which is not instantiated until the information is provided by the client. It is referred to a jargon for plain templates.

Cass template: The individual construction of a class is specified by a class template which is almost similar the way how individual objects are constructed by using a class. It is referred to a jargon for plain classes.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.
FOLLOW US