Inheritance Reading Assignment

  1. Parent contract that other contracts derive from
  2. all public & internal functions
  3. similar to simple inheritance but one parent contract derives into multiple child contracts
1 Like
  1. What is the base contract?
    The parent contract from which other contracts derive

  2. Which functions are available for derived contracts?
    All public and internal functions of the parent contract

  3. What is hierarchical inheritance?
    A tree structure where a node has only one parent and can have one or multiple children

1 Like

Hi @kopino4,

Q1 & Q2 :ok_hand:

This would be correct if by node you mean contract, and had said "and has one or more siblings" (brothers and sisters)

Hierarchical inheritance refers to an inheritance relationship between contracts where more than one child contract derives from a single parent. In other words, a derived contract in this relationship will have “siblings” which it doesn’t inherit from or which don’t inherit from it.

Where a single parent contract is inherited by only one child, this is known as single inheritance, not hierarchical inheritance.

Let us know if anything is unclear, or if you have any questions :slight_smile:

**1. What is the base contract?
The base contract is also know as the parent contract and all children contract inherit from the base.

**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?
It’s when a single contract acts as base contract for multiple derived contracts.

1 Like

Yes I agree, I wanted to describe the tree data structure in computer science in general

1 Like
  1. The base contract is the parent contract from which inherits the child contract.
  2. All public and internal scoped functions.
  3. When a single contract acts as a base contract for multiple derived contracts.
1 Like
  1. The parent contract. It’s the contract which is copied by the compiler into the derived contract and a single contract is created with inheritance.

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

  3. Hierarchical inheritance helps in inheriting the variables, functions, modifiers, and events of base contracts, however a single contract acts as a base contract for multiple derived contracts.

1 Like
  1. What is the base contract?
    It is the parent contract.

  2. Which functions are available for derived contracts?
    All public and internal scoped functions from a base contract.

  3. What is hierarchical inheritance?
    It is inheritance, where a single contract acts as a base contract for multiple derived contracts.

1 Like

-the base contract is the contract inherited by another contract
-Public functions and internal functions, state variables also are
-inheritance of contract by multiple derived contracts

1 Like
  1. What is the base contract?
    The contract which becomes inherited by other contract, i.e. the parent contract

  2. Which functions are available for derived contracts?
    All public and internal scoped functions and state variables from the base contract

  3. What is hierarchical inheritance?
    When a parent can have multiple child (derived) contracts

1 Like
  1. The base contract is the parent contract or the contract inherited from.

  2. All public and internal (not external?) functions are available to derived contracts.

  3. Hierarchical inheritance defines a relationship where multiple contracts are based on one base contract.

1 Like

NIce answers @1984 :ok_hand:

Just to clarify…

…state variables also need to have public or internal visibility to be inherited. Those marked private are not inherited.

Yes… a single contract.

Good answers @ppoluha :ok_hand:

Correct… functions with external or private visibility are not inherited.

What is the base contract?
The base contract is the parent contract from which other contracts inherit.
Which functions are available for derived contracts?
Functions within the derived contract, plus all public and external functions of the parent contract.
What is hierarchical inheritance?
Hierarchical inheritance means that the base contract acts as parent for multiple derived contracts.

1 Like

Hi @tenbad,

Q1 & 3 :ok_hand:

Q2

… functions with public and internal visibility in the parent contract are inherited by the derived contract — external functions aren’t inherited.

That’s correct… multiple derived contracts all inherit from the same single base contract.

1 Like
  1. The base contract is the parent contract.
  2. All state variables and also all public and internal functions.
  3. Hierarchical inheritance occurs when a single contract acts as a base contract for multiple derived contracts.
1 Like

Hi @thecryptoargie,

Q1 & Q3 :ok_hand:

Q2 Which functions are available for derived contracts?

State variables also need to have public or internal visibility to be inherited. State variables marked private are not inherited.

1 Like
  1. The parent.
  2. public and internal
  3. A parent contract acts as a base for multiple derived contracts
1 Like
//What is the base contract?
// This is the contract that is inherited, the Parent 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 base contract for multiple derived contracts
1 Like
  1. The parent contract. The contract which is derived from, not the derived contract.
  2. All public and internal. The purpose of internal is to expose it to derived contracts!
  3. When multiple contracts inherit from the same base contract.
1 Like