This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
c_brain_teasers [2010/09/02 10:16] – created Jan Stancek | c_brain_teasers [2015/10/05 16:07] – Jan Stancek | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <sxh c> | ||
+ | #include < | ||
+ | #include < | ||
+ | class B | ||
+ | { | ||
+ | public: | ||
+ | B(int b) : m_b(b) {} | ||
+ | operator int() | ||
+ | { | ||
+ | return m_b; | ||
+ | } | ||
+ | |||
+ | int operator()() | ||
+ | { | ||
+ | return m_b*2; | ||
+ | } | ||
+ | |||
+ | private: | ||
+ | int m_b; | ||
+ | }; | ||
+ | |||
+ | class A | ||
+ | { | ||
+ | public: | ||
+ | A(int i) | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | int k = 6; | ||
+ | A a( B(k) ); | ||
+ | |||
+ | // what is the output of this program? | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | </ |