Solidity

為什麼我可以在 remix IDE 的繼承契約中呼叫私有函式,而這不應該發生?

  • April 2, 2022
pragma solidity ^0.8.0;

contract Base {

   function privateFunc() private pure returns (string memory) {
       return "private function called, ya dig";
   }

   function testPrivateFunc() public pure returns (string memory) {
       return privateFunc();
   }

   function internalFunc() internal pure returns (string memory) {
       return "internal function called";
   }


}

contract A is Base {
   function test() public view returns (string memory) {
       return internalFunc();
   }
}

testPrivateFunc不是私有函式,即使它正在呼叫私有函式。

引用自:https://ethereum.stackexchange.com/questions/125245