⟩ What is local class in C++?
Local class is define within the scope of a function and nested within a function.
E.g.
int func1()
{
class localclass1
{.....};
}
Local class is define within the scope of a function and nested within a function.
E.g.
int func1()
{
class localclass1
{.....};
}
What is the validity of template parameters? a) inside that block only b) inside the class c) whole program d) any of the mentioned
Which of the things does not require instantiation? a) functions b) non virtual member function c) member class d) all of the mentioned
Which keyword can be used in template? a) class b) typename c) both a & b d) function
What is the output of this program? #include <iostream> using namespace std; template <class T, int N> class mysequence { T memblock [N]; public void setmember (int x, T value); T getmember (int x); }; template <class T, int N> void mysequence<T,N> setmember (int x, T value) { memblock[x] = value; } template <class T, int N> T mysequence<T,N> getmember (int x) { return memblock[x]; } int main () { mysequence <int, 5> myints; mysequence <double, 5> myfloats; myints.setmember (0, 100); myfloats.setmember (3, 3.1416); cout << myints.getmember(0) << 'n'; cout << myfloats.getmember(3) << 'n'; return 0; } a) 100 b) 3.1416 c) 100 3.1416 d) none of the mentioned
What is the output of this program? #include <iostream> using namespace std; template <class T> T max (T a, T b) { return (a>b?ab); } int main () { int i = 5, j = 6, k; long l = 10, m = 5, n; k = max(i, j); n = max(l, m); cout << k << endl; cout << n << endl; return 0; } a) 6 b) 6 10 c) 5 10 d) 6 5
What is the output of this program? #include <iostream> using namespace std; template <class type> class Test { public Test() { }; ~Test() { }; type Funct1(type Var1) { return Var1; } type Funct2(type Var2) { return Var2; } }; int main() { Test<int> Var1; Test<double> Var2; cout << Var1.Funct1(200); cout << Var2.Funct2(3.123); return 0; } a) 100 b) 200 c) 3.123 d) 200 3.123
Can you please explain the difference between a template class and class template?
What is meant by template parameter? a) It can be used to pass a type as argument b) It can be used to evaluate a type. c) It can of no return type d) None of the mentioned
Which parameter is legal for non-type template? a) pointer to member b) object c) class d) none of the mentioned
Why we use template-template parameter? a) binding b) rebinding c) both a & b d) none of these