Creating contracts using the new operator
A contract can create a new contract using the new
keyword . The complete code for the contract being created must be known.
Let's demonstrate, as follows:
contract sample1 { int a; function assign(int b) { a = b; } } contract sample2{ function sample2() { sample1 s = new sample1(); s.assign(12); } }