10th Day                                                                                                                          
 will cover some concepts:
          INHERITANCE :   
- Inheritance is an aspect of OOPs languages.
 - which provides the ability of a program to create a new class from an existing class.
 - The class whose members are inherited is called the base class, and the class that inherits those members is called the derived/child/subclass. In child class, we can override or modify the behaviors of its parent class.
 - Syntax:
 
                          class <Class_name>
                                {
                                   // methods and fields
                                 }
                            Child class:
- We can use it for Code Reusability.
 - We can use it for Method Overriding.
 - This is called IS RELATIONSHIP i.e. Customer IS A CHILD OF Lead.
 

         TYPES OF INHERITANCE:  
- Single Inheritance: it can inherit properties and behavior from at most one parent class.
 - Multilevel Inheritance: In this case a derived class is derived from another derived class.
 - Multiple Inheritance :When an object or class inherits the characteristics and features form more than one parent class.
 - Hierarchical Inheritance: In this case, More than one subclass is inherited from a single base class.
 - Hybrid Inheritance: In this case, A class inherits the characteristics and features from more than one form of inheritance.
 

           CONSTRUCTOR:    
 
- A Constructor is a special type of function of typescript class and it will be automatically invoked when the first object of class is created.
 - TypeScript only allows one constructor implementation.
 - Suppose, In above Example we have required default values like address or anything.
 - For Example: We have created two class Lead & Customer in Customer.ts .
 - Customer.ts:
 
 - Now here ,we have created Client.ts which will invoke Customer and Lead class :
 
- After Compilation: Using tsc -- init
 
- So here tsconfig.json file has been created successfully like Example:
 
- Just Run Client.js file through teminal: node Client.js address will give as output.
 
- Suppose if it has constructor in parent class then first fire it.
 
- Public: It is accessible outside or anywhere the class.
 - Private: it is only accessible inside the class.
 - Protected: It is only accessible in inherited classes and own classes we can't access outside.
 
- So friend If you have any mistakes in any articles you can send me on my email:1809raushan@gmail.com.
 
Thank You...







No comments:
Post a Comment