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 Mar 1, 2018
1 parent f6ae1f3 commit c9bb3db
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 @@ -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 <abstract-contract>`.

.. index:: ! base;constructor

Arguments for Base Constructors
Expand Down Expand Up @@ -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
******************
Expand Down

0 comments on commit c9bb3db

Please sign in to comment.