Inheritance

Solidity

परिभाषा

Inheritance Solidity में एक mechanism है जो contract को दूसरे contract के properties और methods को inherit करने की अनुमति देता है। Solidity multiple inheritance support करता है। यह code reuse और modular architecture के लिए powerful tool है।

English version

Inheritance is a mechanism in Solidity that allows a contract to inherit properties and methods from another contract. Solidity supports multiple inheritance. It is a powerful tool for code reuse and modular architecture.

Code Example

// Contract parent
contract Ownable {
    address public owner;

    constructor() {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }
}

// Héritage
contract MyToken is Ownable {
    function mint() public onlyOwner {
        // Seul le owner peut appeler
    }
}

संबंधित शब्द

Solingo पर इस concept को practice करें

Inheritance को interactive exercises और integrated IDE के साथ master करें।

मुफ्त में शुरू करें