Skip to content

Commit

Permalink
Add section on Constructors in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Jan 3, 2018
1 parent 9a3402b commit 6cfbdec
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,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.19;

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 <abstract-contract>`. Child contracts of an abstract contract can call the super constructor.

.. index:: ! base;constructor

Arguments for Base Constructors
Expand Down Expand Up @@ -1025,6 +1050,8 @@ As an exception, a state variable getter can override a public function.

.. index:: ! contract;abstract, ! abstract contract

.. _abstract-contract:

******************
Abstract Contracts
******************
Expand Down

0 comments on commit 6cfbdec

Please sign in to comment.