reset password
Author Message
chriscarlson91
Posts: 3
Posted 18:17 Feb 06, 2016 |

not sure what is means to overload the constructer keep getting errors?

ltburruel
Posts: 3
Posted 16:58 Feb 10, 2016 |
chriscarlson91 wrote:

not sure what is means to overload the constructer keep getting errors?

What errors are you getting?  

An overloaded constructor is when a class contains more than one constructor.  Often one constructor will take no arguments and set default values and another constructor will take parameters which allow you to initialize an object with values other than the default values.  

Box shoebox = new Box();   // Calling constructor with no parameters  

Box shoebox = new Box(width, height, depth);  // Calling another constructor that takes parameters

 

Since 'Box' has two constructors, one that doesn't take any parameters and one that does, the constructor is overloaded.