Syntax for "class Template and function template"? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Syntax for "class Template and function template"?

19th Dec 2016, 12:41 AM
Arun Vishwakarma
Arun Vishwakarma - avatar
3 Antworten
+ 2
For class and function - template <class T>; But in class in main() you have to declare datatype of class main() { BCA <datatype> obj; ... }
20th Dec 2016, 4:42 AM
Dixem
Dixem - avatar
+ 1
and what about the function template?? himanshu??
20th Dec 2016, 4:49 AM
Arun Vishwakarma
Arun Vishwakarma - avatar
+ 1
Here an example : template <class T> incre(T &x) {T w; w=x++; cout<<w; } int main() { int y; float z; incre(y); incre(z); return 0; }
20th Dec 2016, 5:05 AM
Dixem
Dixem - avatar