Can i call a constructor within a member function ?Is it an example of constructor chaining? Is constructor chaining valid in the latest C++ version?(like what we have in C#)
-
possible duplicate stackoverflow.com/questions/7349183/constructor-chaining-in-cminus– minus2012-08-23 18:24:13 +00:00Commented Aug 23, 2012 at 18:24
-
You can call constructors and desctructors directly, but I would be careful with that. Are you trying to achieve something like: stackoverflow.com/questions/2494471/… ?Marcus Riemer– Marcus Riemer2012-08-23 18:26:19 +00:00Commented Aug 23, 2012 at 18:26
-
@MarcusRiemer:No,I read that constructor chaining was invalid in c++ i just wanted to know if it is supported lately or not, and i also wanted to know if i could call a constructor from a member function or not.The link minus posted has the most simarilty to my question (actually my question was raised because of the same article, app asked about.)Hossein– Hossein2012-08-23 18:35:05 +00:00Commented Aug 23, 2012 at 18:35
Add a comment
|
1 Answer
1) Yes
2) No, calling a constructor from a function is not constructor chaining.
3) Yes, it is called Delegating Constructors
1 Comment
David Rodríguez - dribeas
1) probably not in the sense he intends (calling a constructor on your own object)