04-29-2011, 08:08 AM
what is difference between a constructor and over loaded constructor?
|
what is difference between a constructor and over loaded constructor?
|
|
04-29-2011, 08:08 AM
what is difference between a constructor and over loaded constructor?
04-29-2011, 08:08 AM
As constructor is a special function of class, and like other c++ functions its name also be overloaded. Overloading is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). In overloaded constructor parameters are initialized with user supplied data, while in simple constructor parameters are initialized with default values.
Example: Student::Student (int aRollNo) { //Overloaded constructor if(aRollNo<0){ rollNo=0; } else { rollNo=aRollNo; } 0300-9520262 Get solution in 24 hour |cpmputer & internet mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
|
|
« Next Oldest | Next Newest »
|