Last active
April 12, 2018 22:20
-
-
Save fidsteve/87fdd61996dfa04085161aecbc363690 to your computer and use it in GitHub Desktop.
Cannot create instance in contract because of overloaded constructor - Answer Test Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
contract DynamicContract { | |
bytes32 public Name; | |
function DynamicContract (bytes32 name) public { | |
Name = name; | |
} | |
function foo () public view returns (bytes32) { | |
return (Name); | |
} | |
} | |
contract Factory { | |
address[] contractList; | |
function Factory () public { | |
} | |
function createContract (bytes32 name) public { | |
DynamicContract dynamicContractInstance = | |
new DynamicContract(name); | |
contractList.push(dynamicContractInstance); | |
} | |
function getName(uint ordinal) public view returns (bytes32) { | |
DynamicContract to_get = DynamicContract(contractList[ordinal]); | |
// return newContracts[ordinal].Name(); | |
return to_get.foo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment