can we override constructors?
can we override constructors?
No, you can't override a constructor. They're not inherited. However, each subclass constructor has to chain either to another constructor within the subclass or to a constructor in the superclass.
Asia Affordable Web Hosting Provider
Constructor is a method which have same name as class name and no return value.
Overriding means what we have declared in Super class, that exactly we have to declare in Sub class it is called Overriding. Super class name and Sub class names are different.
So as We can not declare same class(with same constructors) twice in same program, hence we can not Override Constructor.
AccuWebHosting.Com | ASP.Net Hosting Provider Since 2003
₪ Cloud Powered Hosting | Windows VPS | Dedicated Servers
₪ US Based Hosting Company | Trusted by 20,000+ Clients Worldwide
No we cannot override the constructor. A constructor is a special member function of class with the same name as that of class. Its primary purpose is to initialize the data members of the instance of the class. Hence saying that it initializes the data members of the class would be wrong.
Product Manager for Cloud - cloud hosting for quickbooks desktop i.e. QuickBooks Cloud | Migration Expert - Exchange Online Migration and sharepoint migration from 2013 to 2019
|
Bookmarks