Please explain this... for my exams

Please explain this to me. this is for my exams.

class Metro
{
int Mno, Tripno,passengercount;
public:
Metro(int Tmno=1)
{Mno=Tmno;Tripno=0;passengercount=0;}
void Trip(int pc=20){Trip no++;passengercount+=pc;}
void statusshow()
{cout<<Mno<<":"<<Tripno<<":"Passengercount<<endl;}
};
void main()
{
Metro m(5),T;
M.Trip();
T.Trip(50);
M.statusshow();
M.Trip(30);
T.statusshow();
M.statusshow();
}
waiting for responses
What specifically needs explaining? What don't you understand?
answer for the 1st programme is
5:1:20
1:1:50
5:2:50

and there is one similiar programme which I got the answer and in the same way I could not find out the answer for 1st programme.

the other programme is :

class Train
{
int Tno, Tripno,personcount;
public:
Train(int Tmno=1)
{Tno=Tmno;Tripno=0;personcount=0;}
void Trip(int TC=100)
{Trip no++;passengercount+=TC;}
void show()
{cout<<Tno<<":"<<Tripno<<":"Personcount<<endl;}
};
void main()
{
Train T(10),N;
N.Trip();
T.show();
T.Trip(70);
N.Trip(40);
N.show();
T.show();
Answer for this is
10:0:0
1:2:140
10:1:70

I know this . But in the same way I cannot find out the 1sst one.

Have you tried stepping through it with your debugger and look at various variable values?
Topic archived. No new replies allowed.