I'm interested in knowing the order of constructor evaluation when using delegation.
Here's a snippet of my code:
Number(){
length = 100;
values = new int[length];
};
Number(int len) : Number(){
length = len;
}
Note that they both modify length, but only one applies that length to a new array (that's what delegation is for!). This code works.
My question: Why does it work? Do the constructors only apply the code that is non-redundant? Or maybe, in this situation, the default constructor is called before the code in the non-default constructor?
Thanks for your time!
Aucun commentaire:
Enregistrer un commentaire