- The base contract is the parent contract that children derive from.
- Functions with public and internal access modifiers.
- Hierarchical inheritance is multiple contracts deriving from a single base contract.
-
The contract that others derive from, also known as the parent contract.
-
All public and internal scoped functions.
-
A single contract acts as a base for multiple derived contracts.
Inheritance Reading Assignment
What is a base contract?
The base contract is the contract from which another contract has been inherited is called the base contract.
Base contract ==> Parent Contract ==> Child Contract
Which functions are available for derived contracts ?
All public and internal functions of the base contract can be inherited.
What is hierarchical inheritance?
When multiple contracts inherit from the same base contract it is said to have hierarchical inheritance.
1. What is the base contract?
It is the contract that is inherited, thus the parent contract.
2. Which functions are available for derived contracts?
All functions of visibility private and internal.
3. What is hierarchical inheritance?
It’s when a base contract acts as a base for several contrats.
- The base contract is the parent contract that chid contracts inherit.
- Derived contracts have all public and internal defined functions and state variables available.
- Hierachical inheritance implies that contract functionality is inherited from contracts that are higher in the hierarchy.
-
The contract that is inherited is called the parent contract, which is also called as base 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.
- What is the base contract?
A base contract is a main structural solution representation of a problem domain.
- Which functions are available for derived contracts?
Functions, modifiers and state variables.
- What is hierarchical inheritance?
Parent-child contract relationships where the child can access to the parent functions/modifiers/state variables (if public).
-
Base contract is the parent of the inherited contract.
-
All public and internal scope functions and state variables are available for derived contract(s).
-
Similar to single inheritance but with more child links (either more levels or many children at one level).
- It is the term used to identify the parent contract when considering inheritance.
- All public and internal scoped functions coming from the parent contract.
- It is similar to single inheritance, but in this case the parent contract is the base for multiple derived contracts.
-
In Solidity inheritance (like in Java, C++) is allowed that means Solidity is an object oriented programming language. That being said, If you want to create multiple smart contracts, you can use inheritance, which means that individual smart contracts can inherit functions and variables from each other. The smart contract which defines the basis of all following smart contacts and on which all following smart contracts are based is called parent contract or base contract.
-
The derived contracts owns or better to say can use all functions or variables from the base contract as long as they are defined in a why which allows the access to it (public and internal declaration). When you use private and exclude in contrast to the aforementioned “words” as a visibility declaration the derived smart contracts cannot use the the functions/variables.
-
In hierarchical inheritance exist only one smart contract where all other derived smarts contracts inherits from. That means there is only one “level” below the basic smart contract. There is no smart contracts which inherits the functions/variables from an already derived smart contract. All smart contracts inherits there functions and variables direct from the base contract.
- What is the base contract?
- the parent contract of the derived contract(s)
- Which functions are available for derived contracts?
- public and internal functions
- what is hierarchical inheritance?
- when the base contract (parent) derives multiple contracts (children)
I thought I’d read last year that the new Solidity would not have contract inheritance.
Scary berries!
What a relief that was a false alarm.
- What is the base contract?
The base contract is the most parent contract, the one deepest in the hierarchy of
inheritance. - Which functions are available for derived contracts?
All public and internal functions in the parent contract are available to the derived
contract. - What is hierarchical inheritance?
Hierarchical inheritance is when more than one contract inherits directly from a
parent contract.
What is the base contract?
Parent contract is known as a base contract.
Which functions are available for derived contracts?
All public and internal scoped functions and state variables are available for derived contracts.
What is hierarchical inheritance?
A single contract acts as a base contract for multiple derived contracts.
1.) Base contracts are the parenting contracts that child contracts inherits from.
2.) All the functions from it’s parent(s) contracts.
3.) A single contract that acts as a base for multiple child contracts.
- The contract your derived contract inherit from.
- Functions that are internal and public functions.
- When a single contract serves as the base contract for derived contracts.
1.-
Solidity supports the concepts related to Object Oriented Programming. One base principle of OOP is inheritance. One contract can derive some elements from another one through the mechanism of inheritance. In that case the contract that inherits from another one is called “child” because of that relationship, the “parent” is called base contract too.
2.-
All the functions that have access modifier such as public or internal.
3.-
It only means that one base contract can have one or more contracts that inherits from it. All those that inherit directly are at the same level. Since there can be many levels this is referenced as hierarchical inheritance.
Hey @Chillie!
Spot on for questions 1 & 3
You’re right that derived contracts inherit from their parent(s), but not necessarily all the functions — only those that have public or internal visibility, and not those marked private
for example.
Keep up the good work!
Great stuff @EdsonRamirez!
Yes… as the base contract for more than one (multiple) derived contracts.
Great! @cryptoGerry
Just a minor comment…
That’s a really good definition of multiple inheritance
You only need 2 levels for it to be hierarchical inheritance (your definition in the first part of your answer that I’ve quoted above). When you have many levels there is still a hierarchy, as you rightly say, but we can now term this multiple inheritance when we also have more than one contract inheriting from parents.
I hope that clarifies things further, rather than confuses!
Ahh yeah forgot about the internal and private visibility.