Can we use virtual as well as override for the same function?

Hi @Pradhumnya,

Welcome to the community.

Yes. We can use override to override a function from a contract we are inheriting from (the parent contract needs to have marked the function virtual) and make the function virtual to allow contracts inheriting from ours to override.

See the Solidity documentation for details: https://solidity.readthedocs.io/en/v0.6.12/contracts.html#function-overriding

I assume that you are creating a Crowdsale.
Crowdsales are not part of OpenZeppelin Contracts 3.x but can still be used in OpenZeppelin Contracts 2.x: https://docs.openzeppelin.com/contracts/3.x/crowdsales

I suggest looking at: Points to consider when creating a fungible token (ERC20, ERC777)

[Also] When extending contracts, you can call super, see the documentation for details: https://docs.openzeppelin.com/contracts/3.x/extending-contracts#calling_super

1 Like