Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c_brain_teasers [2010/09/02 10:16]
Jan Stancek created
c_brain_teasers [2015/10/05 16:07]
Jan Stancek
Line 1: Line 1:
 +<sxh c>
 +#include <​stdlib.h>​
 +#include <​stdio.h>​
  
 +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("​Output is: %d\n", i);
 +        }
 +};
 +
 +int main()
 +{
 +    int k = 6;
 +    A a( B(k) );
 +
 +    // what is the output of this program?
 +
 +    return 0;
 +}
 +
 +</​sxh>​
Back to top
c_brain_teasers.txt · Last modified: 2015/10/05 16:07 by Jan Stancek
Sitemap Search: