Simple String Template(C++ Programming ) Questions and Answers
Explanation:- Answer: Option D. -> 4
The following are legal for non-type template parameters: integral or enumeration type, Pointer
to object or pointer to function, Reference to object or reference to function, Pointer to member.
Explanation:- Answer: Option A. -> same as template
None
Explanation:- Answer: Option A. -> type-safe
The compiler can determine at compile time whether the type associated with a template definition
can perform all of the functions required by that template definition.
Explanation:- Answer: Option B. -> 2
There are two types of templates. They are function template and class template.
Question 5. What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
template
5.
void print_mydata(T output)
6.
{
7.
cout
1 2 3 4
Explanation:- Answer: Option B. -> 2
Answer:a Explanation: In this program, We are passing the value to the template and printing it in the template. Output: $ g++ tem2.cpp $ a.out 5.5 Hello World