Why is the above code working???
Code:
#include <iostream.h>
class room
{
int length;
int width;
public:
room(int l=10,int w=0):
width(w),
length(l)
{
}
void putdata()
{
cout<<length<<" ";
cout<<width<<" ";
endl;
}
};
int main(void)
{
room objroom1;
room objroom2(12,8);
objroom1.putdata();
objroom2.putdata();
getch();
return 0;
}
just see the constructor?and please tell me how is it working perfectly?see the : at the end of room and see the pair of empty braces if you remove them the code isn't working! Please tell me what is the compiler interpreting from this?