Solidity 040 FunctionPolymorphism

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.9;

// Contract name: FunctionPolymorphism

// Demonstrates the concept of function polymorphism where multiple functions

// have the same name but differ in the type or number of their parameters.

contract FunctionPolymorphism {

  // Function: GetVariableData

  // Purpose: Returns the input data without modification.

  // Parameter: data (int8) - A signed 8-bit integer.

  // Returns: int8 - The same value as the input parameter.

  function GetVariableData(int8 data) public pure returns(int8) {

    return data;

  }

  // Function: GetVariableData

  // Purpose: Returns the input data without modification.

  // Parameter: data (int16) - A signed 16-bit integer.

  // Returns: int16 - The same value as the input parameter.

  // Note: This is an overloaded version of the GetVariableData function that accepts a different data type.

  function GetVariableData(int16 data) public pure returns(int16) {

    return data;

  }

}

//Deploy:

Solidity 040 FunctionPolymorphism_第1张图片

你可能感兴趣的:(Solidity,区块链,金融,智能合约,分布式账本,信任链)