Inheritance Reading Assignment

  1. What is the base contract?
    Inheritance: The contract that is inherited is called the parent contract. The parent contract is known as the base contract.
  2. Which functions are available for derived contracts?
    All public and internal scoped functions.
  3. What is hierarchical inheritance?
    It is similar to single inheritance, however a single contract acts as a base contract for multiple derived contracts
1 Like

@filip in the blog section on Multiple Inheritance:
It says
Contract D is A,B,C {

}
Because B is A and C is A how come D is not like this
Contract D is B,C {

}
Won’t Solidity already include the bytecode for A this way too…?

Thanks!
Brian

1 Like
  1. Base contract is a parent contract from which other contracts are inherited.
  2. All internal/public functions are available from base contracts to inherited contracts.
  3. Hierarchical inheritance is where a single base contract is inherited by multiple derived contracts.
1 Like

Nice answers @cryptopowers :ok_hand:
… and good to see you back here in the forum :smiley:

Well spotted @bdoherty :+1:
You are absolutely right. While including Contract A   in   Contract D is A, B, C   is not incorrect, and will compile and execute successfully, it is unnecessary for Contract D to explicity inherit Contract A, because it will inherit it via Contract B or C. So your suggestion is an improvement:

Nice answers @fahad :ok_hand:
…just be careful with the term inherited.
The parent/base contract is inherited by the child/derived contracts.
So…

The parent/base contract is the contract from which the derived contracts inherit

They are available from inherited base contracts to derived contracts.

I’m sure this is what you meant, though :wink:

What is the base contract?

The contract that is inherited is called the parent contract and the contract that inherits is called the child contract.
The parent contract is known as a base contract.

Which functions are available for derived contracts?

functions marked with the following visibility types public or internal.

What is hierarchical inheritance?

When a single contract acts as a base contract for multiple derived contracts.

1 Like
  1. A base contract is a contract that is inherited from.

  2. All public and internal scoped functions and state variables from the base contract are available in derived contracts.

  3. Hierarchical inheritance in Solidity is when more than one derived contract inherits from the same base contract.

1 Like
  1. What is the base contract?
    = It is the parent contract.

  2. Which functions are available for derived contracts?
    = All public or internal scoped functions.

  3. What is hierarchical inheritance?
    When a base contract has multiple derived contracts.

1 Like

1. What is the base contract?

the parent contract is known as the base contract

2. Which functions are available for derived contracts?

All public and internal scoped functions

3. What is hierarchical inheritance?

When a single contract acts as a base for multiple derived contracts

1 Like
1. What is the base contract?
	a. The contract has a known as the derived class and the parent contract is known as base contract. 
2. Which functions are available for derived contracts?
	a. Inheritance is mostly about code-reusability. Internal scoped functions and state variables are available to derived contracts.
	
3. What is hierarchical inheritance?

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

1 Like

1. What is the base contract? The parent contract

2. Which functions are available for derived contracts? Public and internal functions of the derived contract.

3. What is hierarchical inheritance? Similar to simple inheritance but the base (parent) contract is derived in multiple child contracts

1 Like

Hi @siratoure95,

Q1 & Q3 :ok_hand:

Yes, but not only functions and state variables with internal visibility — functions and state variables with public visibility too.

Nice answers @HardlyCodeMan :ok_hand:

Just one observation…

It’s the public and internal functions of the parent contract (not the derived/child contract) which are inherited… but I think this may have just been a slip, and this is what you meant anyway :wink:

Thanks for the feedback @jon_m,

Yes my slip up, upon re-reading the article referenced in the course while generally grammatically correct, it could have been phrased differently in some of the more poignant areas of differentiation which I believe caused the slip up.

1 Like
  1. The parent contract is the base contract and the contract that is inherited.
  2. All functions and variables are available for derived contracts.
  3. With hierarchical inheritance, the top contract acts as a base contract for multiple derived contracts.
1 Like

Hi @AaronRene,

Q1 & Q3 :ok_hand:

No, not all functions and variables 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.

  1. The base contract is the parent contract that the child is derived from. The child contract inherits the data and functionality of the parent contract.

  2. Public and Internal functions are available to derived contracts.

  3. That is when a parent has more then one child contract.

1 Like

1.- The base contract is the parent contract from which inheritance is started.

2.- All functions and state variables are available to a derived contract from base, unless visibility restricts the function or variable.

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

1 Like
  1. Base constract is the one from witch other contracts inherit from
  2. Derived contracts have all Public and Internal functions of the base.
  3. When a contract give inheritance to many derived contracts.
1 Like