C++ Programming
SPECIALIZATION MCQs
Total Questions : 10
None
There are two types specialization. They are full specialization and partial specialization.
In this program, We are defining three templates and specializing it and passing the values to
it and printing it.
Output:
$ g++ spec5.cpp
$ a.out
6default10
In this program, We are computing the result in the specalized block of the program.
Output:
$ g++ spec3.cpp
$ a.out
template
Answer:d
Explanation:In this program, We are passing the value of specified type and printing it by specialization.
Output:
$ g++ spec2.cpp
$ a.out
1
1
1.2
In this program, We specifed the type in the template function. We need to compile this program by adding -std=c++0x.
Output:
$ g++ -std=c++0x spec1.cpp
$ a.out
2.1: 378.228
None
When you allocate memory for an array of objects, the default constructor must be called to
construct each object. If no default constructor exists, you’re stuck needing a list of pointers
to objects.
In the template specialization, it will make the template to be specific for some data types.
What is the output of this program?
1.
#include
2.
using namespace std;
3.
template
4.
inline T square(T x)
5.
{
6.
T result;
7.
result = x * x;
8.
return result;
9.
};
10.
template
11.
string square(string ss)
12.
{
13.
return (ss+ss);
14.
};
15.
int main()
16.
{
17.
int i = 2, ii;
18.
string ww("A");
19.
ii = square(i);
20.
cout
Template specialization is used when a different and specific implementation is to be used for a
specific data type. In this program, We are using integer and character.
Output:
$ g++ spec.cpp
$ a.out
2:4AA
Recent Questions
Q. A Static Function
Q. Specify The Material Of Construction Suitable For Handling C....
Q. Data Collection Terminals Gather Data For Use By The
Q. Living Together Of A Man And Woman Without Being Married To ....
Q. The Role Of Asp 102 And His 57 During Trypsin Catalysis Is T....
Q. Which Of The Following Formulas Will Excel Not Be Able To Ca....
Q. The Included Angle For The V-belt Is Usually
Q. (solve As Per The Direction Given Above)
Q. Two Cards Are Drawn Together At Random From A Pack Of 52 Car....
Q. The Radius Of Fluorine Atom Is
Q. Which Of The Following Statements Is Incorrect?
Q. What Are the Different Categories Of Plants? Explain. [....
Q. Fermentation Medium For Oxytetracyclin (terramycin) Consist ....
Q. Suspended Solids Are Measured By Which Of The Following?
Q. In A Cantilever Of Span Subjected To A Point Load Of W Actin....
Q. Which Among The Following Is Related To The Word Mesoderm ?
Q. In The Pour Plate Method, The Mixed Culture Is Diluted Direc....
Q. COMFORT
Q. The News Agency Reuters Belongs To Which Of The Following Co....
Q. Very Small Amount Of Air Pollutants Are Present In Stratosph....