1.

Which among the following is the proper syntax for the template class?(a) template ;(b) Template ;(c) template T named(T x, T y){}(d) Template T1 named(T1 x, T2 y){}I have been asked this question by my school teacher while I was bunking the class.This key question is from Template Class topic in chapter Classes of Object Oriented Programming

Answer»

Correct option is (C) TEMPLATE T named(T x, T y){}

Easiest EXPLANATION - The syntax must START with keyword template, case sensitive. Then it should include the typename and a variable to denote it. Then whenever that variable is used, it REPLACES it with the data type needed.



Discussion

No Comment Found

Related InterviewSolutions