Tuesday, October 23, 2012

Question 9: Predict the output.
          class DemoClass
    {
    public:
        DemoClass(int value)
        {
            m_data = value;
        }
        void display()
        {
            std::cout<<"Value : "<<m_data;
        }
    private:
        int m_data;
    };

    int main()
    {
        DemoClass obj = 10;
        obj.display();
    }

    Options:
    a)     Compilation Error    error C2440: 'initializing' : cannot convert from 'int' to 'DemoClass'

    b)    Run time crash.

    c)     Value : 10

    d)    None of the above.


    Answer: c

No comments:

Post a Comment