Constructor overloading in cpp
If you have some confusion or you don't know what constructor is
see how
About author: Unknown
Subscribe to:
Post Comments (Atom)
#include<iostream.h> class room { int length ,width,height ; public: room() // default constructor { } room(int x,int y) // constructor with // two argument { length=x; width=y; } room(int x,int y,int z) // constructor with // three argument { length=x; width=y; height=z; } }; int main() { room obj; //calling default constructor room obj1(20,10); // calling constructor with // two argument room obj2(20,10,12); // calling constructor with // three argument }
0 comments: