From c9bb3db61833136c5a5b3179bfe94db53c4f2c15 Mon Sep 17 00:00:00 2001 From: elenadimitrova Date: Sun, 31 Dec 2017 16:29:45 +0200 Subject: [PATCH] Add section on Constructors in documentation --- docs/contracts.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/contracts.rst b/docs/contracts.rst index 416dc6499bce..d30a71403ce6 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -955,6 +955,31 @@ 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``. + +:: + + pragma solidity ^0.4.11; + + 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 `. + .. index:: ! base;constructor Arguments for Base Constructors @@ -1027,6 +1052,8 @@ As an exception, a state variable getter can override a public function. .. index:: ! contract;abstract, ! abstract contract +.. _abstract-contract: + ****************** Abstract Contracts ******************