Find the errors in the following program and correct them.
[Assume the necessary header files and namespaces included]
class test
{ static int x;
int y;
public:
test( ){x=0;y=0;}
static void display()
{ cout<<x<<”\t”<<y<<endl; }
void output()
{cout<<x<<”\t”<<y<<endl;}
};
int main()
{ test T1;
T1.display();
test::output();
return 0;
}
#include <iostream>
using namespace std;
class test{
static int x;
int y;
public:
test( ){
y=0;
}
static void display()
{
cout<<x<<"\t"<<endl; }
void output()
{cout <<x<<"\t"<<y<<endl;}
};
int test::x=1;
int main()
{ test T1;
T1.output();
test::display();
return 0;
}
Comments
Leave a comment