Question #239531

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;

}


Expert's answer

#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;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS