Read through the blog post linked in the lecture, then answer the following questions. Post your answers in this forum thread.
- What is the base contract?
- Which functions are available for derived contracts?
- What is hierarchical inheritance?
Read through the blog post linked in the lecture, then answer the following questions. Post your answers in this forum thread.
The contract that is inherited is the parent contract
.All public and internal functions and state variables are available for derived contracts.
Hierarchical inheritance is again similar to simple inheritance. Here, however, a single contract acts as a base contract for multiple derived contracts.
The base contract is the parent contract. Also known as the contract from which the child contracts, or derived contracts, derive public and internal functions, state variables, modifiers, and events.
Functions defined using the public or internal scope.
It’s a type of inheritance where instead of one parent contract and one child contract, there is one parent contract and multiple child contracts deriving from it.
Inheritance - Reading Assignment
1. What is the base contract?
2. Which functions are available for derived contracts?
3.What is hierarchical inheritance?
1. What is the base contract?
The base contract is the parent from which the child contract(s) derive from.
2. Which functions are available for derived contracts?
The child contract inherits all functions and state variables with visibility public or internal.
3. What is hierarchical inheritance?
Hierarchical inheritance occurs when the graph of parent child relationships between contracts has multiple branches. I.e “B is A”, “C is A”, and “D is B”. This can also lead to multiple inheritance where branches converge- i.e. “E is A, B, C, D”.
1.What is the base contract?
It is a Parent Contract.
2.Which functions are available for derived contracts?
All public and internal scoped functions and state variables are available to derived contracts.
3.What is hierarchical inheritance?
A single contract acts as a base contract for multiple derived contracts.
The base contract, also called “father” contract is the contract which will have other contract/s that inherit/s variables / functions / modifiers and events to his son/child.
public and internal functions;
Contract A{}
Contract B is A{}
Contract C is A {}
It has to do with inheritance. It is the contract from where other contracts inherit the features.
All public and internal scoped functions.
It is similar to simple inheritance. However, in hierarchical inheritance a single contract “A” acts as a base contract for multiple derived contracts such as “B”, “C” and “D” for instance.
It’s the parent contract, where a child contract inherits from.
All public and internal scoped functions of the base contract (same goes for internal and public state of the base contract)
When multiple contracts use the same base contract.