0

What is the output of the following C program?

[gamipress_button type=”submit”  label=”Run Code Online” onclick=”window.open(‘https://coderseditor.com’,’_blank’)”]


#include<iostream>
using namespace std;

class Test
{
private:
    static int count;
public:
    static Test& fun();
};

int Test::count = 0;

Test& Test::fun()
{
    Test::count++;
    cout<<Test::count<<" ";
    return *this;
}

int main()
{
    Test t;
    t.fun().fun().fun().fun();
    return 0;
}

 

Studently Answered question October 10, 2022