-
The base contract is the parent contract where other contracts inherit from.
-
All public and internal functions are available to derived contracts
-
This is when the parent contract can be derived from multiple contracts
Inheritance Reading Assignment.
-
The Base Contract is the parent contract of a derived contract (It inherits the features of the parent).
-
The functions that are available for derived contract are all public and internal scoped functions and state variables.
-
Hierarchical Contract is a single contract acting as a base contract for multiple derived contract.
Hi @deanb3,
Q1 & Q3
Q2
No, not all functions in the base/parent contract are inherited. Public and internal functions are available for derived contracts, but not those with private or external visibility. The same is true for state variables and mappings.
Q3
Correct — when a single parent contract is inherited by multiple derived contracts
Hi @MrSeven
Q1 & Q3
Q2
Yes, but not all functions in the base/parent contract are inherited. Public and internal functions are available for derived contracts, but not those with private or external visibility. The same is true for state variables and mappings.
Q1 & Q3
Q2
Yes, internal and public functions are available for derived contracts, but not those with private or external visibility.
Hi @RCV
Q1 & Q3
Q2
Yes, but not all functions and variables in the base/parent contract are inherited. Public and internal functions are available for derived contracts, but not those with private or external visibility. The same is true for state variables and mappings.
However, visibility is not declared for modifiers and events, so you are right that all of the modifiers and events declared in a parent/base contract are available for use in its derived contract(s).
Hi @DUUKA_SMASH ,
Q1 & Q3
Q2
No, not all functions in the base/parent contract are inherited. Public and internal functions are available for derived contracts, but not those with private or external visibility. The same is true for state variables and mappings.
However, visibility is not declared for modifiers and events, so all of the modifiers and events declared in a parent/base contract are available for use in its derived contract(s).
Also, a derived contract can have its own function declarations, so not all of the functions available for a derived contract are inherited from its parent.
Hi @Depth-Hoar,
Q1 & Q2
Q3
No — you’ve got this the wrong way round: hierarchical inheritance is where multiple child contracts can be derived from a single parent contract.
Nice answers @madingo
This is a definition of hierarchical inheritance (not a hierarchical contract, which isn’t a term we use).
Thanks Jon,
Maybe you can help me , I cant get the remix complier to compile the helloWorld contract so it can be inherited by Ownable and destroyable. The latter two are the only ones that compile. I need help, because I cannot continue the practical version of lesson. Do you think you might know this issue? Thanks
JF
Hi Javier,
Post a copy of the HelloWorld contract you have, which isn’t compiling, then I’ll be able to see what the problem is.
… but post it to the Inheritance Assignment discussion topic, so it’s in the right thread
In fact post your full destroyable.sol file too, as the issue might be there instead.
Hi Jonathan,
Thanks for the feedback. Your correction is well noted.
- The “base contract” is the parent contract, which is inherited by derived contracts.
- For derived contracts all functions from the base contract are available that are declared “public” or “internal”, but not those with “private” or “external” visibility. (The same applies for state variables etc.)
- Hierarchical inheritance is a single contract that acts as a base contract for multiple derived contracts.
Base is the parent contract
Public and Internal scoped functions are available for derived contracts
One parent contract that has multiple child contracts
- What is the base contract?
The parent contract that is inherited by the child one.
- Which functions are available for derived contracts?
Public and internal functions will be available for the child contracts.
- What is hierarchical inheritance?
A single contract as the base/parent contract, and then multiple contracts inheriting from it.
What is the base contract?
Smart contracts are considered objects and solidity is an object oriented programming language. So a parent contract giving “inheritance” to a child contract is also called a “base” contract.
Which functions are available for derived contracts?
All public and internal scoped functions and state variables are available to derived contracts
What is hierarchical inheritance?
The possibility for a child contract to become a “parent” (sounds really beautiful!!!)
Hi @cincinnato,
Q1 & Q2
Q3
That does sound beautiful, and can also happen. But that’s not what the term hierarchical inheritance actually refers to. It is where more than one child contract is derived from the same parent contract.
What is the base contract?
The base contract is the parent class in the parent-child relationship in solidity.
Which functions are available for derived contracts?
Functions with visibility levels of public or internal.
What is hierarchical inheritance?
When one base contract act as a parent to multiple derived contracts.
- What is the base contract?
The base contract is the contract at the highest point of the contract hierarchical structure. It is the parent of one or more child contracts and does not have a parent contract itself. - Which functions are available for derived contracts?
Functions with visibility of public and internal are available to derived contracts. - What is hierarchical inheritance?
Hierarchical inheritance is a contract inheritance structure wherein multiple child contracts derive from a single parent contract.