What will be the output of the following C++ code? [code] #include <iostream> using namespace std; class sample {

Huyền Thu

New member
What will be the output of the following C++ code?
Code:
    #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
Variable entered is 5
B. Runtime error
C. Error
D.
Enter an integer 7
Variable entered is 7
 

Tìm kiếm

Back
Top