template<class T, class X> class Obj {
T my_t;
X my_x;
public:
Obj(T t, X x) : my_t(t), my_x(x) { }
};
Referring to the sample code above, which one of the
following is a valid conversion operator for the type T?
a) T operator T () { return my_t; }
b) T operator(T) const { return my_t; }
c) operator(T) { return my_t; }
d) T operator T (const Obj &obj) { return obj.my_t; }
e) operator T () const { return my_t; }



template<class T, class X> class Obj { T my_t; X my_x; public: Obj(T t, X ..

Answer / guest

option 'e' is the correct one

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

How does code-bloating occur in c++?

0 Answers  


What is the difference between public, private, and protected access?

0 Answers  


Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }

2 Answers   Impetus,


How do I start a c++ project?

0 Answers  


What is a down cast?

0 Answers  






What is a "RTTI"?

6 Answers   HCL,


Describe new operator and delete operator?

0 Answers  


Why do we use classes in c++?

0 Answers  


How to defines the function in c++?

0 Answers  


What is c++ 11 and c++ 14?

0 Answers  


What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator?

0 Answers  


what is C++ exceptional handling?

0 Answers  


Categories