Inheritance Reading Assignment

  1. What is the base contract?

A base contract is the parent contract from which the derived contract inherits its characteristics (functions, modifiers, variables, etc.)

  1. Which functions are available for derived contracts?

All functions with keywords internal or public from the parent class will be available to the child classes.

  1. What is hierarchical inheritance?

It is inheritance structure where the parent (base) contract provides the foundation for several child contracts that are derived from it.

  1. The base contract is also called the “parent contract”. Other “child contracts” derive from the base contract, or other contracts inherit from the base contract.
  2. Functions with the encapsulation “public” and “internal”.
  3. Several derived contracts (child contracts) inherit from one base contract.

1 The base contract is the contract, the child contract inherits from.
2 The derived contract will inherit all functions from the base contract
3 Several contracts can be derived from one base contract.

The blog post is a bit confusing: all of a sudden when “multiple inheritance” is illustrated, the arrows are reversed. Why? Is it just wrong or is it me?
But this will perhaps be explained by @filip in the next lesson. :slight_smile:

image

The base contract is the parent contract.

The visibility of the functions has to be internal or public

The parent/child relationship that may extend is the basis of hierarchical inheritance.

  1. The base contract is the parent contract. It is the contract that is inherited into the child contract via the is keyword.

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

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

1. What is the base contract?
This is a contract from which other contracts inherit. Also called parent contract.
2. Which functions are available for derived contracts?
Ones that are not private.
3. What is hierarchical inheritance?
If contract B inherits from A and contract C inherits from B then C also inherits from A.

  1. What is the base contract?

The parent contract (that is inherited by child contract)

  1. Which functions are available for derived contracts?

internal & public functions

  1. What is hierarchical inheritance?

single contract act as a base contract for multiple derived (child) contracts

I would also like to share some typo mistake of the code of this blog post regarding abstract contract vs interfaces. The example of the interfaces part seems to be incorrect (typo due to copy & paste I guess).

Abstract Contract Example

contract abstractHelloWorld {
      function GetValue() public view returns (uint);
      function SetValue(uint _value) public;
      function AddNumber(uint _value) public returns (uint) {
        return 10;
      }
}

contract HelloWorld is abstractHelloWorld{
      uint private simpleInteger;
      function GetValue() public view returns (uint) {
        return simpleInteger;
      }
 
      function SetValue(uint _value) public {
        simpleInteger = _value;
      }
     function AddNumber(uint _value) public returns (uint ){
       return simpleInteger = _value;
     }
}

Interfaces Example

contract InterfaceHelloWorld {
      function GetValue() public view returns (uint);
      function SetValue(uint _value) public;
}

contract HelloWorld is InterfaceHelloWorld{
      uint private simpleInteger;
      function GetValue() public view returns (uint) {
        return simpleInteger;
      }
 
      function SetValue(uint _value) public {
        simpleInteger = _value;
      }
}
  1. What is the base contract?

The contract itself has a parent which is called the derived class and the parent contract is known as the base contract.

  1. Which functions are available for derived contracts?

There is a relationship between base and derived contracts and all public and internal scoped functions and state variables are available to derived contracts.

  1. What is hierarchical inheritance?

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

  1. What is the base contract?

The base contract is also known as parent contact and is essentially the contract (or class) derived from when applying the OOP principle of inheritance in Solidity on a contract.

  1. Which functions are available for derived contracts?
  1. All of the functions declared in the base contract(s)
  2. All of the functions declared in the derived contract
  1. What is hierarchical inheritance?
  1. Hierarchical inheritance is when a single contract acts as a base contract for multiple derived contracts

1- base contract is the parent contract from which the children contracts inherit functions, variables, modifiers, etc

2- all functions not set as private from the parent contract are available in the derived contracts

3- when we have multiple (different) children contracts inheriting from a single base parent contract, it is allowed for children of the children also to inherit, thus getting all the information from previous generation

  1. What is the base contract?
    It’s the parent contract, the one that is inherited.

  2. Which functions are available for derived contracts?
    All functions from the parent contract that aren’t private.

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

  1. The base contract is the parent contract when a child contract is related to the parent through inheritance.

  2. All functions flagged as either public or internal are available for derived contracts.

  3. Hierarchical inheritance is where multiple contracts are derived from one parent contract.

  1. When a contract has a parent known as the derived class and the parent contract is known as a base contract.

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

  3. Hierarchical inheritance is when a single contract acts as a base contract for multiple derived contracts.

  1. The base contract s the contract that is inherited (also called the parent contract).
  2. All public and internal scoped functions (as well as state variables) are available for derived contracts.
  3. Hierarchical inheritance is when one contract serves as a base contract for multiple child contracts, each of them on the same level in the parent-child relation.

1.a base contract is defined as a parent contract for any contract(s) that makes use of the base contract’s variables and functions via the is keyword and all such contract(s) are known as child contract/derived contract.

2.a child contract inherits all of the base contract codes but can only access and makes use of variables and functions that are set to public & internal. .

3.a hierarchy inheritance is when a base contract has multiple child contracts or when multiple contracts share the same base contract.

1 Like
  1. What is the base contract?
    The base contract is the parent contract that child contracts can inherit from.

  2. Which functions are available for derived contracts?
    All public and internal functions in both the base contract and the derived contract.

  3. What is hierarchical inheritance?
    When multiple derived contracts inherit from a single base contract.

1 Like
  1. What is the base contract?
  • The base (or parent) contracts are the ones from which other contracts inherit.
  1. Which functions are available for derived contracts?
  • All public and internal scoped functions and state variables are available to derived contracts.
  1. What is hierarchical inheritance?
  • Hierarchical inheritance is similar to simple inheritance. A single contract can act as a base contract for multiple derived contracts
1 Like
  1. The base contract is a parent contract. Other contracts inherit the functions from the base/parent contract.
  2. All public and internal scoped functions and state variables
  3. Hierarchical inheritance is where a single contract acts as a base contract for multiple derived contracts
1 Like

1. What is the base contract?
The base contract is the most parent contract.

2. Which functions are available for derived contracts?
Public and Internal functions are available for contracts to derive from.

3. What is hierarchical inheritance?
Hierarchical inheritance is the parent-child relationship of contracts and the scope of how data is shared between them.

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

  2. Which functions are available for derived contracts?
    Internal and public functions and state variables.

  3. What is hierarchical inheritance?
    is when a contract is the base contract of multiple derived contracts.

1 Like