File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed
Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 11# Encapsulation
2- Encapsulation is a process of wraping or combine state and methods (behavior) in a single unit or single container.
2+ Encapsulation is a process of wraping/ combine/bind properties and methods (behavior) in a single unit or single container.
33
44![ https://www.sitesbay.com/cpp/images/encapsulation-in-cpp.png ] ( https://www.sitesbay.com/cpp/images/encapsulation-in-cpp.png )
55
66all state is private , cannot change the state. Only can change with public function.
77
88~ Encapsulation or information hiding
99
10- ~ Hide internal states and values inside a class
10+ ~ Hide internal states and values inside a class, (safe the modification of state)
1111
1212``` php
1313class Cat
Original file line number Diff line number Diff line change 22
33* Poly means many and morphism means forms.
44
5- ~ interface
5+ ## interface
6+
7+ * Interface is blueprint of class and abstract method that means only have method thare have no implementation.
8+
9+ * each method will be public
10+ * method have no implementation but implemented class all methods has implementation
11+ * don't have constructor method
12+
13+ ## overriding
14+
15+ * Parent have a method and same method have the child class.that time override the parent method.
16+
17+ ``` php
18+ class Employee
19+ {
20+ public function salary()
21+ {
22+ return 20000;
23+ }
24+ }
25+
26+ class SoftwareEngineer
27+ {
28+ public function salary()
29+ {
30+ return 35000;
31+ }
32+
33+ public function details()
34+ {
35+ echo "Software engineer salary = " . $this->salary();
36+ }
37+ }
38+
39+ $softwareEngineer = new SoftwareEngineer();
40+ $softwareEngineer->details()
41+ ```
42+
43+ ## overloading
644
745# resources
846
You can’t perform that action at this time.
0 commit comments