- base concract is a parent contract
- all
- single contract acts as a base contract for multiple derived contracts
No⦠not all functionsā¦those with public or internal visibility are available for derived contracts. Functions with private or external visibility are not available.
-
What is the base contract?
The contract that is inherited called parent contract, also known as a base contract. -
Which functions are available for derived contracts?
All public and internal scoped functions and state variables are available to derived contracts. -
What is hierarchical inheritance?
A single contract acts as a base contract for multiple derived contracts.
1- Itās a contract that has a child contract
2- All public and internal (no external)
3- Hierarchical inheritance refers to a contract that is the base for several children contracts
Nice answers @raul782
Yes, thatās correct⦠and as well as external
functions, private
functions are also not available.
1: The base contract is the root or parent contract of the rest.
2: public and internal functions and state variables are available.
3: A single base contract that has (child) contracts under it derived from it.
Yes⦠more than just one child contract.
-
What is the base contract?
Foundation contract that acts as a base by providing
necessary variables, functions, modifiers, and events.
Solidity copies the base contract into the derived contract and
a single contract is created with the inheritance. A single
address is generated that is shared between the two
contracts. -
Which functions are available for derived contracts?
Modifiers such as external, public, internal and private affect the visibility of state variables within the contract in which they are defined, inheriting child contracts or outside contracts. -
What is hierarchical inheritance?
A single contract acts as a base contract for multiple derived
contracts.
- The base contract is the parent contract.
- All the public and internal scoped contracts of the base contract are available for derived contracts.
- In hierarchical inheritance a single contract acts as the base contract for multiple derived contracts.
- The base contract also called the parent contract is the contract that other āchildā contracts inherit or derive code from.
- The public and internal functions created in the base contract are available for a derived contract.
- In hierarchical inheritance a single contract acts as the base contract for multiple derived contracts.
Thanks Filip for putting your code in Githuib!! Huge help!!
Hi @dani88,
Q1 & 3
These 4 visibility types are used to define the visibility of both state variables and functions.
Not all of the functions or state variables in a parent/base contract are inherited by (available to) derived/child contracts. Those with public or internal visibility are available. But those with external or private visibility are not available.
Nice answers @PhilD99
Iām sure it was just a slip⦠but this should be:āāAll the public and internal scoped functionsā¦ā (not contracts).
So, what is the difference between external and private?
Hi @dani88,
private
visibility: only accessible from within the same contract i.e not accessible from derived contracts, external contracts, or from external services.
external
visibility: accessible from external contracts and external services, but not accessible from within the same contract or from any derived contracts (i.e. the opposite of internal
visibility)
- What is the base contract?
The base contract is also known as the parent contract.
- Which functions are available for derived contracts?
All public and internal scoped functions & state variables are available to derived contracts.
- What is hierarchical inheritance?
Hierarchial inheritance is when a single contract acts as a base contract for multiple derived contracts.
- What is the base contract?
It is the contract where all the methods & variables are defined. Further they can be viewed, used or modified by the other classes based on access modifiers specified in the base contract.
- Which functions are available for derived contracts?
Public functions : Available to all contracts includes derived contract.
Internal functions : Available within the contract only & contracts derived from it.
Private functions : Not available to derived contract.
- What is hierarchical inheritance?
Itās like a simple inheritance but the only difference is that it can derived by the multiple
contracts.
-
What is the base contract?
the parent contract is known as a base contract -
Which functions are available for derived contracts?
All public and internal functions and state variables are available to derived contracts. -
What is hierarchical inheritance?
When a single contract acts as a base contract for multiple derived contracts.
- parent contract
- polymorphism
- base contract acts as a base for multiple contracts
Hi @Bhushan_Pawar,
Q2 & 3
Yes⦠it is where more than one child contract is derived from the same parent contract.
I think youāve got a bit confused here, and overcomplicated thingsā¦
The base contract is the parent contract , the contract which is inherited by the child (or derived ) contract .
No⦠not all the functions and variables. A derived contract usually contains most of the functions and variables. It also inherits the public and internal functions and variables in its parent contract(s), and which are also available to the derived contract when it is deployed.
Let us know if anything is unclear, or if you have any questions