0

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#)

3
  • possible duplicate stackoverflow.com/questions/7349183/constructor-chaining-in-c Commented 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/… ? Commented 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.) Commented Aug 23, 2012 at 18:35

1 Answer 1

5

1) Yes

2) No, calling a constructor from a function is not constructor chaining.

3) Yes, it is called Delegating Constructors

Sign up to request clarification or add additional context in comments.

1 Comment

1) probably not in the sense he intends (calling a constructor on your own object)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.