Inheritance Reading Assignment

Hi @guillaume_M-D,

Good point, but this public “default visibility” only applies to state variables. You have to define the visibility of a function otherwise the compiler rejects it. And the question was specifically about which functions are available to derived contracts (not state variables) :wink:

Not everything else — don’t forget there is also external visibility, and a function or state variable marked as external will only be inherited by other smart contracts that are also not derived contracts.

It’s so good that you are really thinking about what the standard answer actually means though, as that’s the best way to understand what is really going on in practice :slightly_smiling_face:

  1. What is the base contract? Is the parent contract i.e the contract that is inherited.
  2. Which functions are available for derived contracts?- Public and internal
    functions are available to derived contracts.
  3. What is hierarchical inheritance?One parent contract many children contracts i.e a single contract acts as a base contract for multiple derived contracts.
1 Like
  1. What is the base contract? Inheritance is one of the pillars of object orientation and Solidity supports inheritance between smart contracts. The contract that is inherited is called the parent contract and the contract that inherits is called the child contract. Similarly, the contract has a parent known as the derived class and the parent contract is known as a base contract.

  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?
    Hierarchical inheritance is again similar to simple inheritance, but here a single contract acts as a base contract for multiple derived contracts.

1 Like
  1. What is the base contract?
    A base contract is the parent contract that is being inherited by child contracts.

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

  3. What is hierarchical inheritance?
    It’s when one contract acts as a base parent to multiple children contracts which inherit the parent’s functions.

1 Like

What is the base contract?

  • Parent contract
  • The contract that is inherited is called the parent contract. Inheritance is the process of defining multiple contracts that are related to each other througth parent-child relationships.

Which functions are available for derived contracts?

  • Function polymorphism
  • Contract polymorphism

What is hierarchical inheritance?

  • here a single contract acts as a base contract of mulitple derived contracts.
1 Like
  1. The parent contract is known as base contract.
  2. All public and internal scoped functions and state variables are available to derived contracts.
  3. A single contract acts as a base contract for multiple derived contracts.
1 Like

Hi @const9090,

Q1 & 3 :ok_hand:

Q2

No… functions with public or internal visibility are available for derived contracts.

  1. Base contract or parent contract, is the contract from which programming code is inherited.
  2. All public and internal scoped functions and state variables are available for derive contracts.
  3. When more than one contracts are derived from a single base contract.
1 Like
  1. What is the base contract? Also known as parent contract which is inherited from.
  2. Which functions are available for derived contracts? Public and internal functions including state variables can be used by derived contracts.
  3. What is hierarchical inheritance? The parent / base contract acts as a root for inheritance for multiple derived 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 and state variables are available to derived contracts.

  3. What is hierarchical inheritance?
    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 parent contract. This is the contract that child contracts inherit from.

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

  3. What is hierarchical inheritance?
    When a parent contract is a base contract for multiple derived contracts (child contracts)

1 Like
  1. The contract that is inherited is called the parent contract.This contract is also known as a base contract.
  2. All public and internal scoped
    functions and state variables are available to derived contracts
  3. A single contract acts as a base contract for multiple derived contracts
2 Likes
  1. What is the base contract?
    The contract that is inherited.

  2. Which functions are available for derived contracts?
    all the public, external and internal functions are available for derived contracts, except private functions.

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

1 Like
  1. The base contract is the contract from which all of its children contracts are derived
  2. The public or internal functions that were in the parent base contract will be inherited to the derived contract.
  3. A single base contract inherits to several derived contracts.
1 Like
  1. The base contract is a contract which derived contracts inherit from

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

  3. A contract is the base contract for multiple derived contracts

1 Like

.

  1. What is the base contract?
    The base contract is like the parent contract and a child inherits from the father.

  2. Which functions are available for derived contracts?
    public, internal

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

1 Like
  1. Base contract is a parent contract. The original contract by which there is a child or derived contract.
  2. The functions of the base contracts.
  3. A type of inheritance where a base contract can be a parent for multiple derived contracts.
1 Like
  1. What is the base contract?

    • The contract that inherits from the parent contract.
  2. Which functions are available for derived contracts?

    • abstract
    • interfaces
  3. What is hierarchical inheritance?

    • It is a base contract that derives from two Parent Contracts.
    • Less used features are put into the derived contracts (Parent contract) .
1 Like

1- The parent contract.
2- All public and internal scoped functions and state variables are available to derived contracts
3- It’s similar to simple inheritance except there are multiple contracts involved in a hierarchical relationship to one another.

1 Like
  • What is the base contract?
    In the process of defining multiple contracts that are related to each other through parent-child relationships, the parent contract is known as a base contract . It is the contract that is inherited by the child contract .
  • Which functions are available for derived contracts?
    Inheritance is mostly about code-reusability. There is a is-a relationship between base and derived contracts and all public and internal scoped functions and state variables are available to derived contracts. In fact, Solidity compiler copies the base contract bytecode into derived contract bytecode. The is keyword is used to inherit the base contract in the derived contract. It is one of the most important concepts that should be mastered by every Solidity developer because of the way contracts are versioned and deployed.
  • What is hierarchical inheritance? A simple inheritance helps in inheriting the variables, functions, modifiers, and events of base contracts into the derived class. Hierarchical inheritance is again similar to simple inheritance. Here, however, a single contract acts as a base contract for multiple derived contracts.
1 Like