Home » C++ Programming » Pointers » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class N
    {
    public:
    N(int k = 0){ _k = k;}
    void fun()
    {
    cout << "Program Executed..."< }
    private:
    int _k;
    };
    int main()
    {
    N *ptr = 0;
    ptr -> fun();
    }
    1. Program Executed...
    2. Compilation Error
    3. Runtime Error
    4. Garbage value
    5. None of these
Correct Option: A

In this program, We passes the value to the class and printing it.



Your comments will be displayed only after manual approval.