Inheritance Reading Assignment

Added to my notes, thanks!

1 Like
  1. What is the base contract?
    the contract that is being inherited from

  2. Which functions are available for derived contracts?
    they have visibility “internal” and “public”

  3. What is hierarchical inheritance?
    when multiple contracts inherit from the same base contract

1 Like
  1. Parent contract from which the child contract derives.
  2. All public functions, internal functions, and state variables.
  3. Single contract acts as a base contract for multiple derived contracts.
1 Like

1. What is the base contract?
The base contract is also referred to as the parent contract, it is the contract that is inherited by other contracts below it(child contract)
2. Which functions are available for derived contracts?
all functions that are public and internal. as well as variables (stored variables)
3. What is hierarchical inheritance?
A hierarchical inheritance is when multiple derived(child) contracts inherit from the same base (parent) contract.

1 Like
  1. Base contract is inherited contract, we can also call it parent contract.

  2. In derived contracts, which we can also call child contract are available public and internal functions.

  3. Hierarchical inheritance is where a single contract acts as a base contract for multiple derived (child) contracts.

1 Like
  1. What is the base contract?
    A contract can be inherited by other contracts. the relationship between base contract and those inherit it is known as parent-child.
  2. Which functions are available for derived contracts?
    All public and internal functions.
  3. What is hierarchical inheritance?
    In the condition, a base contract is directly inherited by multiple contracts.
1 Like
  1. What is the base contract?

This is the parent contract that chid contracts can be derived from. this means the functions and variables in this base contract can be used in multiple child contracts that is derived from it by using the IS parameter.

  1. Which functions are available for derived contracts?

All internal and public functions in the parent contract are available in the derived contract.

  1. What is hierarchical inheritance?

this means that the child contract can only inherit the parent contract and not the other way around. it’s a top-down structure. The base contract can be inherited by the contract below it and that contract or contract can then be inherited by another child contract below it. The PArent contract however cannot inherit from the child contract.

2 Likes

1. What is the base contract?
The base contract is the parent contract. It is the contract that is inherited by another. The contract being inherited is the parent and the inheritor is the child.

2. Which functions are available for derived contracts?
The public and internal functions from the parent contract are able to be called in the child contract.

3. What is hierarchical inheritance?
The fact that a base contract can be inherited by multiple contracts.

1 Like

1. What is the base contract?
The base contract is the parent contract of which functions and declarations get inherited by child contracts beneath it.

2. Which functions are available for derived contracts?
Public functions and functions that are internally scoped are able to be inherited by derived contracts.

3. What is hierarchical inheritance?
Hierarchical inheritance exists where there are multiple contracts deriving from a single base contract. This hierarchical structure can propagate the further down the hierarchy goes, where certain derived contracts can become a parent to multiple other contracts.

1 Like

Inheritance reading assignment.

  1. What is the base contract?
    It’s the parent contract that has derived contracts.
  2. Which functions are available for derived contracts?
    All internal scoped.
  3. What is hierarchical inheritance?
    Single contract acts as a base contract for possibly several deriving contracts.
1 Like

1.) What is the base contract?
-The parent contract

2.) Which functions are available for derived contracts?

  • All public and internal scoped functions as well as state variables are available for derived contracts.

3.) What is hierarchical inheritance?

  • Hierarchical inheritance is similar to simple inheritance however a single contract acts as a base contract for multiple derived contracts. For example, you have Contract A, Contract B is A, and Contract C is A.
1 Like

1. What is the base contract?

The parent contract.

2. Which functions are available for derived contracts?

Public functions and functions of internal scope (+ state variables).

3. What is hierarchical inheritance?

Multiple contracts being directly derived from the base contract.

1 Like

Nice answers @jtb :ok_hand:

Just one observation …

Q2 Which functions are available for derived contracts?

Just to be clear, as with functions, not all state variables in the base contract are available for the derived contract:
Public and internal state variables are inherited, but state variables with private visibility are not inherited.

Just let me know if you have any questions :slight_smile:

Nice answers @KennethJP :ok_hand:

Just to be clear …

As with functions, not all state variables in the base contract are available for the derived contract:
Public and internal state variables are inherited, but state variables with private visibility are not inherited.

Just let me know if you have any questions :slight_smile:

Hi @DavidV,

Q1 & Q2 :ok_hand:

This is true of all inheritance structures, not just hierarchical inheritance.

Hierarchical inheritance is the term for a specific type of inheritance structure, where the same, single base/parent contract is inherited by more than one (i.e. multiple) derived/child contracts.

Just let me know if you have any questions.

Hi @TuomoP,

Q1 & Q3:ok_hand:

Yes … and functions marked public are inherited as well.

Nice answers @Bitborn :ok_hand:

Just to be clear, as with functions, not all state variables in the base contract are available for the derived contract:
Public and internal state variables are inherited, but state variables with private visibility are not inherited.

Just let me know if you have any questions :slight_smile:

Nice answers @Julian97 :ok_hand:

Just to be clear, as with functions, not all state variables in the base contract are available for the derived contract:
Public and internal state variables are inherited, but state variables with private visibility are not inherited.

Just let me know if you have any questions :slight_smile:

1 Like

Thanks for making that distinction, it wasn’t that clear to me from the article!

1 Like

1.- The parent contract.

2.- All functions available on the public or internal scope.

3.- When a parent contract inherits to multiple child contracts in a pyramid-like structure, derived contracts.

1 Like