You are on page 1of 3

Adv C++ Test

Adv C++ Test


NAME._______________________ EC NO._______________________ Time 30 min Marks : 20

1. There are two objects c and d. How can we know whether the ha!e been created "rom the same c#ass$ a. %" the typeid o" the two object are same. b. %" the typeid(object).name on the two objects matches.

2. How can o& know the name o" the c#ass o" an object$

3. 'hich o" these dec#arations are correct$ a. template<class T, U, class V> void foo(T, U, V); b. template <class T> T foo(int *T); c. template <class myT, class myT> void foo (myT, myT);

(. )i!en the "o##owin* "&nction tem+#ate de"initions: template <class T>

Page 1 of 3

Adv C++ Test

T min(const T& t1, const T& t ) ! ..." 'hich o" the "o##owin* ca##s, i" an , are errors$ do#ble d1, d ; float f1, f ; c$a% c1, c ; int i1, i ;

a. min(d1, d ); b. min (c1, d1); c. min (i1, c1); d. min (f1, d1);

5. )i!en the "o##owin* tem+#ate de"initions "or s#m() template <class T1, class T , class T&> T1 s#m(T , T&);

'hich o" the "o##owin* ca##s are errors$ do#ble d1, d ; float f1, f ; c$a% c1, c ;

a. s#m(d1, d ); b. s#m <do#ble, do#ble, do#ble> (f1, f ); c. s#m<int>(c1, c );

-. %denti" which, i" an , o" the "o##owin* tem+#ate c#ass dec#arations are i##e*a#$ a. template <class Type, int si'e> class (ontaine%;

Page 2 of 3

Adv C++ Test

b. template <class T, U, class V> class (ontaine%; c. template <class T, class U> class (ontaine%; d. template <class T ) comple*<do#ble>, int v> class (ontaine%;

.. %denti" which, i" an , o" the "o##owin* tem+#ate instantiations are !a#id$ template <int *pt%> class +t% ! ... "; template <class Type, int si'e> class ,i*ed-.%%ay ! ... ";

a. const int si'e ) 1/ 0; +t%<&si'e> bp1; b. int a%%11/2; +t%<a%%> bp ; c. +t%</> bp&; d. const int si'e-val ) 1/ 0; ,i*ed-.%%ay<st%in3, si'e-val> fa1; e. #nsi3ned int fasi'e ) 44;

,i*ed-.%%ay<int, fasi'e> fa ; f. const do#ble db ) &.1014; ,i*ed-.%%ay<do#ble, db> fa&;

Page 3 of 3

You might also like