Find the output of the following program. Find errors if any and correct it.
class test
{ int x;
public:
test(int x)
{x=x; }
void display()
{cout<<x;}
};
int main()
{ test T1(5);
T1.display();
return 0;
}
[Assume the necessary header files and namespaces included]
#include <iostream>
using namespace std;
class test
{ int x;
public:
test(int x)
{this->x=x; }
void display()
{cout<<x;}
};
int main()
{ test T1(5);
T1.display();
return 0;
}
Comments
Leave a comment