Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    class num
    {
    int N;
    public:
    int getN();
    void putN(int M);
    };
    int num::getN()
    {
    return N;
    }
    void num::putN(int M)
    {
    N = M;
    }
    int main()
    {
    num obj;
    obj.putN(15);
    cout << obj.getN( );
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Garbage Value
    4. 15
    5. None of these
Correct Option: D

We are getting the number and copying it to M and printing it.



Your comments will be displayed only after manual approval.