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 {
    int &t;
public:
    Test (int &x) { t = x; }
    int getT() { return t; }
};
  
int main()
{
    int x = 20;
    Test t1(x);
    cout << t1.getT() << " ";
    x = 30;
    cout << t1.getT() << endl;
    return 0;
}

 

Studently Answered question October 11, 2022