When is a template better solution than a base class??
Answers were Sorted based on User's Feedback
Answer / mayank kumar
as template is in form of generic class and generic
function so here the class and function works for all. also
in template we can change the data type of function
parameter as well as of the data member present in class.
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / faruk
1.when you are designing a generic class to contain or otherwise manage objects of other types.
2.when the format and behaviour of those other types are unimportant to their containment or management.
3.particularly when those other types are unknown.
| Is This Answer Correct ? | 3 Yes | 1 No |
int f() { int I = 12; int &r = I; r += r / 4; int *p = &r; *p += r; return I; } Referring to the sample code above, what is the return value of the function "f()"? a) 12 b) 15 c) 24 d) 17 e) 30
What does it mean to declare a member variable as static?
What is the difference between ++ count and count ++?
What are exceptions c++?
What is design pattern?
Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers
Why c++ is faster than java?
Why can templates only be implemented in the header file?
Write a corrected statement in c++ so that the statement will work properly. if (x > 5); y = 2*x; else y += 3+x;
How const functions will be treated by compiler?
Write a program using display() function which takes two arguments.
Why is c++ still popular?