-
code: SimpleStorage simpleStorage = new SimpleStorage(); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Explanation:
Hope this helped! Good luck with the course EDIT: BTW, I would recommend going through basic OOP principles as this is a fundamental concept in Computer Science |
Beta Was this translation helpful? Give feedback.
-
Exactly what @krakxn said. I'd like to elucidate a bit using another example of inheritance (from https://www.geeksforgeeks.org/solidity-constructors/?ref=lbp)
Notice how when the Derived contract is inheriting the Base Contract, the number '2' is being passed as a constructor argument. This is the argument that the Base contract expects in its constructor, which is a uint. Even though the data variable wasn't initialized or assigned a value in the Base contract, it is automatically recognized to be 2, since it was passed as a constructor argument when the contract was being created. The point being, that when you say SimpleStorage simpleStorage = new SimpleStorage(); The last parentheses indicate that NO arguments are being passed to the contract constructor when a new SimpleStorage is created. Hope that helps answer your question. I'm also new but I read this in some really helpful documentation on https://www.geeksforgeeks.org/solidity-constructors/?ref=lbp |
Beta Was this translation helpful? Give feedback.
Explanation:
Hope this helped! Good luck with the course
EDIT: BTW, I would r…