Inheritance Reading Assignment

  1. The base contract is the parent contract that children derive from.
  2. Functions with public and internal access modifiers.
  3. Hierarchical inheritance is multiple contracts deriving from a single base contract.
2 Likes
  1. The contract that others derive from, also known as the parent contract.

  2. All public and internal scoped functions.

  3. A single contract acts as a base for multiple derived contracts.

1 Like

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 Like

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.

1 Like
  1. The base contract is the parent contract that chid contracts inherit.
  2. Derived contracts have all public and internal defined functions and state variables available.
  3. Hierachical inheritance implies that contract functionality is inherited from contracts that are higher in the hierarchy.
1 Like
  1. The contract that is inherited is called the parent contract, which is also called as base contract.

  2. All public and internal functions and state variables are available for derived contracts.

  3. Hierarchical inheritance is again similar to simple inheritance. Here, however, a single contract acts as a base contract for multiple derived contracts.

2 Likes
  1. What is the base contract?

A base contract is a main structural solution representation of a problem domain.

  1. Which functions are available for derived contracts?

Functions, modifiers and state variables.

  1. What is hierarchical inheritance?

Parent-child contract relationships where the child can access to the parent functions/modifiers/state variables (if public).

1 Like
  1. Base contract is the parent of the inherited contract.

  2. All public and internal scope functions and state variables are available for derived contract(s).

  3. Similar to single inheritance but with more child links (either more levels or many children at one level).

1 Like
  1. It is the term used to identify the parent contract when considering inheritance.
  2. All public and internal scoped functions coming from the parent contract.
  3. It is similar to single inheritance, but in this case the parent contract is the base for multiple derived contracts.
1 Like
  1. 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.

  2. 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.

  3. 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.

1 Like
  1. What is the base contract?
  • the parent contract of the derived contract(s)
  1. Which functions are available for derived contracts?
  • public and internal functions
  1. what is hierarchical inheritance?
  • when the base contract (parent) derives multiple contracts (children)
1 Like

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.
1 Like

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 Like

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.

  1. The contract your derived contract inherit from.
  2. Functions that are internal and public functions.
  3. When a single contract serves as the base contract for derived contracts.
1 Like

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.

1 Like

Hey @Chillie!
Spot on for questions 1 & 3 :+1:

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! :muscle: :smiley:

Great stuff @EdsonRamirez! :smiley:

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 :+1:

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! :sweat_smile:

Ahh yeah forgot about the internal and private visibility.