Blockchain
Blockchain
Code:Single Inheritance
// SPDX-License-Identifier: GPL-3.0
// Base contract
contract BaseContract {
string public baseMessage;
constructor() {
baseMessage = "Hello from BaseContract!";
}
// Derived contract
contract DerivedContract is BaseContract {
string public derivedMessage;
constructor() {
derivedMessage = "Hello from DerivedContract!";
}
// Base contract A
contract A {
string internal x;
string a = "Hello";
string b = "World";
Output:
// Declaring internal
// state variable
string internal x;
// Declaring internal
// state variable
uint internal sum;
Output:
// Declaring internal
// state variable
string internal x;
// Defining contract B
contract B {
// Declaring internal
// state variable
uint internal pow;
}
}
Output: