Lesson 3: Inheritance & Overrides | The favoriteNumber is not being inherited from the Simple Storage file. #5819
Replies: 1 comment
-
I just used "private" to the favoriteNumber variable so I could not access it in the other contract. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In the video, Patrick explained to inherit from a contract by using the "imports" and "is" keyword. He tried to add 5 to the favoriteNumber using the store function and it worked, but when i tried to replicate the same it gives me an error saying "Undefined Identifier". Yes, the error is saying that the favoriteNumber has not been declared but it was declared in the inherited file. Patrick did the same but it worked. But for me it is throwing an error while compiling. The code of inherited file is:
`
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
contract SimpleStorage {
uint256 private favoriteNumber;
}
The code of the file where we are trying to override is :
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;
import "./SimpleStorage.sol";
contract ExtraStorage is SimpleStorage {
}`
Can someone please explain what is going on?
Beta Was this translation helpful? Give feedback.
All reactions