#include<iostre am.h>
class Room
{
int length;
int width;
public:
Room()
{}
Room(int l,int w=0) : width(w),length (l)
{
}
};
void main()
{
Room objRoom1;
Room obj2Room2(12,8) ;
}
This program is not giving any error.Now my question is : wat is the signifcance of this type of constructor declaration Room(int l,int w): width(w),legth( l)
y data member is defined as a function declaration and w and l as argument?
Note that commenting :width(w),lengt h(l) does not give error while declaring width= w, length = l is giving error.
CAN ANYONE PLZZZ EXPLAIN THIS TO ME........
class Room
{
int length;
int width;
public:
Room()
{}
Room(int l,int w=0) : width(w),length (l)
{
}
};
void main()
{
Room objRoom1;
Room obj2Room2(12,8) ;
}
This program is not giving any error.Now my question is : wat is the signifcance of this type of constructor declaration Room(int l,int w): width(w),legth( l)
y data member is defined as a function declaration and w and l as argument?
Note that commenting :width(w),lengt h(l) does not give error while declaring width= w, length = l is giving error.
CAN ANYONE PLZZZ EXPLAIN THIS TO ME........
Comment