0

If I have the following contracts:

contract A {
   function _delegate() internal virtual {
      //some code
   }
}
contract B is A {
   //some code not including _delegate()
}
contract C is B {
   function _delegate() internal override {
      //some code
   }
}

..and if I deploy Contract C and call _delegate(), which code will run? The one from Contract A or from Contract C?

1 Answer 1

1

In Contract A: You have the initial _delegate() function.

In Contract B: _delegate() function is inherited, from Contract A.

In Contract C: _delegate() function is inherited, from Contract B, which inherited that function from Contract A.

However, in Contract C you are overriding _delegate() function, so that code will be the valid one.

Answering your question: If you deploy Contract C and call _delegate(), you will get //some code from Contract C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.