Here is the code that instantiates an object form the prior EmployeeDetail2 class. It inputs an employee id. If the id is 0 it invokes the no argument constructor, otherwise it inputs the name and salary and invokes the constructor that takes arguments. On another note I forgot to mention that having multiple constructor with the same name is called overloading. We will see this same term later with methods.
No comments:
Post a Comment