Main Index : Reference :
[void] super(...)
... is one or many parameters separated by commas.
super() should be called at the first line of the constructor of a derived class to run the constructor of the parent class. The parameters are the same as one would pass to the parent if it were allocated with new.
// myClass calls the constructor of its parent, myParent,
// and passes its parameter value along using super(x).
// The parent's constructor then sets its own variable
// value to x.
class myParent
{
private:
var value;
public:
myParent(x);
}
myParent::myParent(x)
{
value = x;
}
class myClass : myParent
{
public:
myClass(x); // Constructor
}
myClass::myClass(x)
{
super(x); // Calls the parent constructor
}
var a = 10.0;
var obj = new(myClass,a);