Skip to content

Commit 91675fa

Browse files
committed
oop
1 parent b6147c5 commit 91675fa

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

encapsulation/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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

66
all 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
1313
class Cat

polymorphism/readme.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,45 @@
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

0 commit comments

Comments
 (0)