Good Question!
Lets explore the constructor inheritance:
Lets look at the following example:
import "dapple/test.sol";
contract A {
bool aHit;
bool public aPublicHit;
bool public aConstructorArg;
bool cHit;
function A(bool _aConstructorArg) {
aHit = true;
aPublicHit = true;
aConstructorArg = _aConstructorArg;
}
}
contract B is A(true) {
bool bHit;
bool public bConstructorArg;
function B(bool _bConstructorArg) {
bHit = true;
bConstructorArg = _bConstructorArg;
}
function checkA() returns (bool) {
return aHit;
}
function checkB() returns (bool) {
return bHit;
}
function checkC() returns (bool) {
return cHit;
}
}
contract T is Test {
function testConstructor() {
B b = new B(true);
//@log constructor A called: `bool b.checkA()`
//@log constructor B called: `bool b.checkB()`
//@log controll call c: `bool b.checkC()`
//@log public call: `bool b.aPublicHit()`
//@log a constructor arguments recieved: `bool b.aConstructorArg()`
//@log b constructor arguments recieved: `bool b.bConstructorArg()`
}
}
If we now run testConstructor function with dapple test --report
we will get the following output:
test constructor
LOG: constructor A called: true
LOG: constructor B called: true
LOG: controll call c: false
LOG: public call: true
LOG: a constructor arguments recieved: true
LOG: b constructor arguments recieved: true
About 1., what would happen if the parent constructor had arguments and I didn't declare it explicitly?
In case:
contract A { function A(bool) { ... }}
contract B is A { ... }
your contract would fail to instantiate:
Error: Trying to create an instance of an abstract contract.
B b = new B(true);
^---^
About 2., I've noticed that there is a public modifier for properties, but I'm not sure of what omitting such modifier defaults to.
The public keyword generates an interface to access the property from outside of the Contract. I hope the example above makes this clear.
If you want to learn more about inheritance, I recommend you reading the following links:
https://solidity.readthedocs.io/en/develop/contracts.html?highlight=inheritance#inheritance
https://solidity.readthedocs.io/en/develop/contracts.html?highlight=inheritance#arguments-for-base-constructors