I want to clear my understanding of this basic OOPS concept in c#. On most of the internet sites, I read that a derived class inherits the private members o
in order to construct a Manager
you need to construct the base class using any constructor in the base class, if there is only one (as in this case) you need to call it. that does not mean you must define a constructor with the same signature.
you would also be allowed to do this:
public Manager() : base(100000)
{
}
or
public Manager(string name, int salary) : base (salary)
{
// store name
}
During construction of you Manager
you will allocate a new object on the heap. This object will claim enough memory so that it can store the variables defined in the base class (Employee
) and concrete class (Manager
).