adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class sample
    {
        private:
        int var;
        public:
        void input()
        {
           cout << var;
        }
        void output()
        {
           cout << "Variable entered is ";
           cout << var << "\n";
        }
    };
    int main()
    {
        sample object;
        object.input();
        object.output();
        object.var();
        return 0;
    }

a.

Enter an integer 5

b.

Runtime error

c.

Error

d.

None of the mentioned

Answer: (c).Error

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?