Created by Yogesh
❤️❤️❤️
Created by Yogesh
❤️❤️❤️
| <body> | |
| <header> | |
| <nav> | |
| <div class="brand"> | |
| <a href="#"> | |
| <img src="https://codersgyan.github.io/spacex-redesign/img/logo.png" alt=""> | |
| </a> | |
| </div> | |
| <div class="nav-right"> | |
| <div class="nav-links"> |
| Virtual function | Pure virtual function |
|---|---|
| A virtual function is a member function of base class which can be redefined by derived class. | A pure virtual function is a member function of base class whose only declaration is provided in base class and should be defined in derived class otherwise derived class also becomes abstract. |
| Classes having virtual functions are not abstract. | Base class containing pure virtual function becomes abstract. |
Syntax: Virtual<func_type><name>{//Code..} |
Syntax:virtual<func_type><func_name>() |
| Definition is given in base class. | No definition is given in base class. |
| Base class having virtual function can be instantiated i.e. its object can be made. | Base class having pure virtual function becomes abstract i.e. it cannot be instantiated. |
| If derived class do not redefine virtual function of base class, then it does not affect compilation. | If derived class do not redefine virtual function of base class, then no compilation error but |
| Abstracion | Encapsulation |
|---|---|
| Abstraction is a process or method of gaining the information | Encapsulation is the process or method to contain the information. |
| In abstraction, problems are solved at the design or interface level | In encapsulation, problem are solved at the implementation level. |
| Abstraction is a methods of hiding the unwanted information. | Encapsulation is a method to hide the data in a single entity or unit along with a method to protect information from outside. |
| we can implement abstraction using abstract class and interfaces. | Encapsulation is implementation using by access modifier i.e Private, public & protected |
| The objects that helps to perform abstraction are encapsulated. | Objects that result in encapsulation need not be abstracted. |
| compile time Polymorphism | Runtime Polymorphism |
|---|---|
| At Compile time, which functions to be called is decided. | At Runtime, which function to be called is decided. |
| Also known as early or static binding | Also known as late or dynamic binding |
| It executes faster because the function is resolved at compilation time only. | It executes slower because the function is resolved at Run-time. |
| It is achieved through function and operator overloading | It is achieved through function overriding and virtual functions |
| import turtle | |
| import math | |
| turtle.Screen().bgcolor("Black") | |
| #t=turtle.Turtle() | |
| def new(): | |
| # colors collection from stackoverflow | |
| colors = [ | |
| #reddish colors | |
| (1.00, 0.00, 0.00),(1.00, 0.03, 0.00),(1.00, 0.05, 0.00),(1.00, 0.07, 0.00),(1.00, 0.10, 0.00),(1.00, 0.12, 0.00),(1.00, 0.15, 0.00),(1.00, 0.17, 0.00),(1.00, 0.20, 0.00),(1.00, 0.23, 0.00),(1.00, 0.25, 0.00),(1.00, 0.28, 0.00),(1.00, 0.30, 0.00),(1.00, 0.33, 0.00),(1.00, 0.35, 0.00),(1.00, 0.38, 0.00),(1.00, 0.40, 0.00),(1.00, 0.42, 0.00),(1.00, 0.45, 0.00),(1.00, 0.47, 0.00), | |
| #orangey colors |
| import turtle | |
| import math | |
| turtle.Screen().bgcolor("Black") | |
| #t=turtle.Turtle() | |
| def new(): | |
| # colors collection from stackoverflow | |
| colors = [ | |
| #reddish colors | |
| (1.00, 0.00, 0.00),(1.00, 0.03, 0.00),(1.00, 0.05, 0.00),(1.00, 0.07, 0.00),(1.00, 0.10, 0.00),(1.00, 0.12, 0.00),(1.00, 0.15, 0.00),(1.00, 0.17, 0.00),(1.00, 0.20, 0.00),(1.00, 0.23, 0.00),(1.00, 0.25, 0.00),(1.00, 0.28, 0.00),(1.00, 0.30, 0.00),(1.00, 0.33, 0.00),(1.00, 0.35, 0.00),(1.00, 0.38, 0.00),(1.00, 0.40, 0.00),(1.00, 0.42, 0.00),(1.00, 0.45, 0.00),(1.00, 0.47, 0.00), | |
| #orangey colors |