diff --git a/docs/contracts.rst b/docs/contracts.rst index fcc26b247397..273a9923c849 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -953,6 +953,29 @@ not known in the context of the class where it is used, although its type is known. This is similar for ordinary virtual method lookup. +.. index:: ! constructor + +Constructors +============ +Constructor is an optional function with the same name as the contract which is executed upon contract creation. +Constructor functions can be either ``public`` or ``internal``. + +:: + + contract A { + uint public a; + + function A(uint _a) internal { + a = _a; + } + } + + contract B is A(1) { + function B() public {} + } + +A constructor set as ``internal`` causes the contract to be marked as :ref:`abstract `. Child contracts of an abstract contract can call the super constructor. + .. index:: ! base;constructor Arguments for Base Constructors @@ -1025,6 +1048,8 @@ As an exception, a state variable getter can override a public function. .. index:: ! contract;abstract, ! abstract contract +.. _abstract-contract: + ****************** Abstract Contracts ******************