Inheritance Reading Assignment

  1. What is the base contract?
    The contract tht is inherited is called the parent contract, it’s also knwon as the base contract - while the contract that inherits is called the child contract.

  2. Which functions are available for derived contracts?
    In Solidity, the “is” keyword is used to inherit the base contract in the derived contract

  3. What is hierarchical inheritance?
    Hierarchical inheritance is when a single contract acts as a base contract for multiple derived contracts.
    Ex:
    Contract A
    /
    Contract B Contract C

1 Like
  1. The contract from which others derive or in other words - this is the parent contract that describes all members (functions and state variables) that each of his children will get as a base through the
    process of inheritance.

  2. The ones declared as public or internal.

  3. In hierarchical inheritance we have 1 base contract which is derived by multiple children and they are usually inherited themselves by other derived contracts, building an hierarchy. It’s important to note that if any of the children or “grand”-children become base class for any “grand”-parent - the whole concept is broken.

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

  2. All there are public and internal scoped functions.

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

1 Like
  1. The base contract is another name for the parent contract.

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

  3. Hierarchical inheritance is when one parent contract serves as the base for multiple derived contracts.

1 Like
  1. What is the base contract? the parent contract
  2. Which functions are available for derived contracts? all the parent functions plus their own functions
  3. What is hierarchical inheritance? multiple contracts that inherit from a parent contract
1 Like

1.What is the base contract?
->It is a contract that has a child 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?
-> It is a structure that one contract acts as a parent contract for multiple contracts.

1 Like
  1. What is the base contract?:
    It’s the contract that has its functionality extended to the child contract.

  2. Which functions are available for derived contracts? :
    All functions that are public or internal.

  3. What is hierarchical inheritance? :
    It’s when a parent contract extends multiple child contracts.

1 Like

Hi @keithra1948,

Q1 & Q3 :ok_hand:

What you have written is correct, but by functions the question means the chunks of a program which can be called/invoked, not syntax such as keywords. Do you know?

Hi @RKumovski,

Q1 & Q2 :ok_hand:

Yes, except that it is inherited (not derived) by multiple children. The multiple children are derived from the single base contract, which is what I’m sure you mean :slight_smile:

Not necessarily… but they can be. One level of two or more derived contracts is enough to generate hierarchical inheritance, but you are right that it could also grow to consist of multiple levels.

I don’t understand what you mean here. Could you try to clarify?

1 Like

Hi @meganova,

Q1 & Q3 :ok_hand:

No, not all functions in the parent contract are inherited. Public and internal functions are available for derived contracts, but not those with private or external visibility. The same is true for state variables and mappings.

Yes… from a single parent contract.

1 Like

I mean that if we have per say Contracts A, B, C, D =>
if B is A
C is B
D is C
and A is D => We’re doing something wrong :smiley:

1 Like

Ah, ok… I understand now… I was a bit concerned that you thought this was a different yet valid inheritance set-up! :sweat_smile: But, as you say, there would definitely be something wrong going on in that scenario, as we’d be trying to create a strange circular relationship! :astonished:

1 Like
  1. The contract that been inherited is called base contract, simply saying, the parent contract.

  2. all internal and public functions are available to derived contracts

  3. Its when few contract has been inherited from one contract, each in their own direct way.

1 Like
  1. The base contract is the one which is inherited. It is also known as the parent contract.
  2. All public and internal scoped functions are available for derived contracts.
  3. Hierarchical inheritance takes place when from one base contract there is at least two derived contracts.
1 Like

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

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

3. What is hierarchical inheritance?
This is when multiple contracts inherit from a single base contract.

2 Likes

Nice answers @ghiasi12reza :ok_hand:

Just to confirm…

Its when multiple contracts (more than one) inherit (or derive) from one contract…
…which I think is what you mean :slight_smile:

1 Like

The base contract is the parent contract; they may contain classes, functions, etc. that can be derived by child contracts.

Functions available to derived contracts are the public and internal functions of the parent contract.

Hierarchical inheritance refers to child contracts gaining access to functions, variables, etc. from a parent contract.

1 Like
  1. What is the base contract?
  • This is the contract from which the child contract inherits from.
  1. Which functions are available for derived contracts?
  • All public, internal functions, and state variables are available for derived contracts.
  1. What is hierarchical inheritance?
  • A single contract(base contract) from which multiple contracts inherit from.
1 Like
  1. What is the base contract?
    This is parent contract that child contract inherit from

  2. Which functions are available for derived contracts?

All public and internal function and also state variables

  1. What is hierarchical inheritance?

multiple contracts that derive from the same base contract.
Contract A is derived in both Contract B and Contract C.

2 Likes

What is the base contract?
It is the parent contract to the contract that inherits it

Which functions are available for derived contracts?
internal and public

What is hierarchical inheritance?
It is when a single contract acts as a base contract for multiple derived contracts

2 Likes