What is the difference between C++’s constructor and Eiffels create procedure declaration?
What value is there in being able to have multiple constructor functions for a class? Or is there any other benefit to Eiffels “create”?
Thankyou
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C++ you can overload constructors, so you can define multiple constructors as well.
Having constructor procedures as in EIFFEL has the advantage, that you can define different constructors having the same signature (i.e. same number and type of arguments).
Just imagine a
Triangleclass: You might want to construct a triangle by giving the lengths of the three sides (three float values), or by giving two sides and the enclosing angle (also three float values).In C++ you would have to define an additional parameter (e.g. a enum value for the ‘construction mode’), in EIFFEL you can simply define two construction procedures with different names.