Inheritance Reading Assignment

1.The base contract is the parent contract, it is the contract that is inherited.
2. Functions, state variables and events are available for derived contracts.
3. A single contract acts as a base contract for multiple derived contracts.

1 Like

Hi @Epicdisaster,

Q1 & Q3 :ok_hand:

Q2 Which functions are available for derived contracts?

Yes, but not all functions and state variables are inherited.

Functions and state variables with public or internal visibility in the base contract are inherited. But functions with external or private visibility, and state variables with private visibility, are not available for derived contracts.

All events and modifiers are inherited.

Let me know if you have any questions.

  1. The base contract, referred to at times as the parent contract, is the contract to where various functions and variables are derived from.
  2. All Public and internal scoped functions.
  3. Where 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 - the contract that another is derived from.

  2. Which functions are available for derived contracts?

All public and internal functions.

  1. What is hierarchical inheritance?

A single contract acting as inheritance for multiple derived contracts.

1 Like
  1. The base contract is the contract that is used to derive other contracts from - the “parent contract”.

  2. The functions available on derived contracts are the public and internal functions.

  3. A single contract is used as base contract for multiple multiple contracts.

1 Like

A) A base contract is the " parent " contract in the parent- child relationship, where the child contracts derived their inheritance from.

B) The availability for derived contracts from the base contracts are variables, functions, modifiers and events.

C) A hierarchical inheritance is where a single contact acts as a base contract for multiple derived contracts

1 Like

Hi @Nuno_Silva,

Q1 & Q2 :ok_hand:

Q3 What is hierarchical inheritance?

I assume you meant to say “multiple derived contracts” :wink:

Hi @ecbwong,

Q1 & Q3 :ok_hand:

Q2 Which functions are available for derived contracts?

Yes, but not all functions and state variables are inherited.

Functions and state variables with public or internal visibility in the base contract are inherited. But functions with external or private visibility, and state variables with private visibility, are not available for derived contracts.

All events and modifiers in the base contract are inherited.

Let me know if you have any questions.

1. What is the base contract?

The parent contract.

2. Which functions are available for derived contracts?

All public and internal scoped functions.

3. What is hierarchical inheritance?

This is when multiple child contracts are derived from the same base parent contract.

1 Like
  1. What is the base contract?
    The original or first source of contract
  2. Which functions are available for derived contracts? Internal and Public functions with state variables are available for deprived contracts
  3. What is hierarchical inheritance? when the parent contract acts the base contract for multiple child contracts
1 Like
  1. The parent contract that is the source of the inheritance.
  2. All public and internal scoped functions are available.
  3. Inheritance where a single contract acts as a base contract for multiple derived contracts.
1 Like

What is the base contract?
parent contract which is inherited by other contracts.

Which functions are available for derived contracts?
public and internal functions are available for derived contracts.

What is hierarchical inheritance?
when there are more than one contract directly inheriting from base contract.
and the derived contract is not inheriting from more than one parent contract(multiple).

1 Like

Nice answers @Saula_Atama :ok_hand:

Just to clarify a couple of points…

While this is often true, we can also have inheritance structures where a base contract can also be the derived contract of another base contract e.g.

// Multi-level inheritance structure
contract A { ... }
contract B is A { ... }
contract C is B { ... }

In this multi-level inheritance structure:
C is a derived contract
A is a base contract… but not the only base contract …
B is both a derived contract (of A), and a base contract (to C)

As with functions, not all state variables in the base contract are inherited. State variables with internal and public visibility are available to derived contracts, but those with private visibility are not inherited.

Just let me know if you have any questions.

1 Like

1.) the parent contract
2.) all public and internal scoped functions
3.) a single contract is the base for multiple derived contracts

1 Like
  1. What is the base contract? It is the contract which is the parent for all the other contracts and gives some attributes and methods to inheritance.
  2. Which functions are available for derived contracts? Functions which are not restricted by the keywords like private.
  3. What is hierarchical inheritance? Hierarchical inheritance is when multiple contracts inherit from one parent contract.
1 Like
  1. What is the base contract?
    • A base contract is the parent contract in which a child class was derived/inherited from
  2. Which functions are available for derived contracts?
    • Public and internal functions are made available to the derived contract.
  3. What is hierarchical inheritance?
    • Where a single (parent) contract acts as a base for multiple derived (child) contracts
1 Like

Nice answers @xRave110 :ok_hand:

This is correct… but to be more specific…
Functions with private or external visibility are not inherited i.e. functions with public or internal visibility in a base contract are available for its derived contract(s).

Just let me know if you have any questions.

  1. What is the base contract?
  • Base contract is a parent contract that can be inherited by the child contracts.
  1. Which functions are available for derived contracts?
  • Public and internal scope functions.
  1. What is hierarchical inheritance?
  • When single parent contract is inherited by multiple child contracts.
1 Like
  1. A base contract is the parent contract that is from the derived class.

  2. all functions available in the parent contract are available to derived contracts.

  3. A hierarchical inheritance is when there is one Parent contracts and multiple child contracts that have a relationship to the single parent contract.

  1. A base contract is a parent contract.
  2. Functions which are public or internal are availble for derived contracts.
  3. This is when a base contract is the parent of multiple child (derived) contracts.