Rewrite the following program after removing the syntactical error(s) if any. Underline each correction.

class employee
{   int no;
    class data
    {   int dd,mm,yy;
	void print_data()
	{  cout<<dd<<mm<<yy;  }
    data dob;
    data doj;
    void prin_t()
    {     doj.print_data();
	   cout<<dob.dd<<dob.mm<<dob.yy;   }
void main()
{    employee 1emp;
     data 2emp;  }

I am studying in +2.
I think the errors are in main function, 1emp is wrong and cannot call data as it is a private function. are there any more corrections?

5 Years
Discussion Span
Last Post by deceptikon

Yes, there are more corrections. How many more depends on the compiler you're using, because this code makes assumptions about the language that aren't supported by modern compilers.

But if you ignore those problems, there are four corrections required to make the code compilable. You have options in what corrections to apply, there may be multiple instances of the same error type, and one correction may fix multiple errors, but there are still four distinct errors that need to be fixed.

Edited by deceptikon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.