![]() |
VOOZH | about |
Encapsulation is fundamental and one of the most important concepts of object-oriented programming languages. It refers to the mechanism of manipulation of the scope of variables, i.e. it restricts the access of the variable outside the scope. It allows enough constraint access to a method for taking action on it. The scope of the objects can have four types of access:
Example: In the below example, the contract parent is inherited by the contract child to demonstrate different scopes of the object discussed above.
Output: Deploy the Caller Contract to get the output of the given Example.
1. Output of f():
{
"0": "uint256: 100"
}
2. Output of f2() :
{
"0": "uint256: 50",
"1": "uint256: 30"
}