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 |
What is a storage class used in c++?
What is virtual base class uses?
What are the data types in c++?
What is oops in c++?
Write a program to show polymorphism in C++?
What is the difference between public and private data members?
What is the benefit of learning c++?
this is to swap to strings....but in output the whole strings are swapped leaving first as it is...why it is so #include<iostream.h> int main() { char a[]="ajeet"; char b[]="singh"; long x=*a; long y=*b; cout<<x<<":"<<y; x=x+y; y=x-y; x=x-y; *a=x; *b=y; cout<<x<<":"<<y; cout<<&a<<endl; cout<<&b<<endl; }
How are pointers type-cast?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Write a program to swap 2 chars without using a third varable? char *s = "A"; char *p = "B";
What is the c++ programming language used for?