Correct the errors with replacement lines


Discuss the below:

Q1) Please correct the errors with replacement lines beside it. And then give short notes on why it is wrong.

class Person
{
private:
char name[30];
int age;

public:
Person (string, int);
int setage (int);
int setname (char *);
void show (void);

};

void main()
{
Person a_group [5];
int i;

for (i=0; i<6; i++)
a_group[i].setage(i+1);

for (i=0;i<6;i++)
cout << "Person " << i+1 << " is " << a_group[i].age << end1;
}

Q2) Please correct the errors with replacement lines beside it. And then give short notes on why it is wrong if the below codes replace the codes between the two === in 1):

void main (void)
{
Person a_person;
a_person.age = 99;
}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Correct the errors with replacement lines
Reference No:- TGS01937918

Now Priced at $25 (50% Discount)

Recommended (96%)

Rated (4.8/5)