Is it possible to make a constructor build an object of the same type it is currently constructing?
constructor Inscription::Inscription(){
id := "my_inscription_id";
text := "1";
graphics := new Graphics();
}
constructor Inscription::Inscription(g : Graphics){
var inscr := new Inscription();
id := inscr.id;
text := inscr.text;
graphics := g.clone();
log("Created Inscription with given graphics");
}
Which is fine with few attributes, but it gets crazy when the number of attributes gets higher. I am looking for something like this:
constructor Inscription::Inscription(g : Graphics){
result := new Inscription(); //Call the other constructor
//id := inscr.id;
//text := inscr.text;
graphics := g.clone();
log("Created Inscription with given graphics");
}