What will be printed as a result of the execution of the following program?
#include <iostream>
using namespace std;

class c1 {
    int i;
public:
    c1(int j) { i = j; }
    int get_i() { return i; }
};

int main()
{
    c1 ob[3] = { 1, 2, 3 };            // 1
    c1 *p = ob;
    
    for(int i = 0; i < 3; i++)
    {
       cout << p->get_i() << " ";      // 2
       p++;
    }

    return 0;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes