root@wotk.UUCP (Superuser) (07/31/90)
I'm curious why the following syntax was chosen for initializing an instance of a class - MyClass X(1,2,3,); instead of the syntax used in C aggregate data types - MyStruct X = {1,2,3}; MyArray X = {1,2,3}; Is it to emphasize the fact that a constructor function will be called? Curious, Nick Hennenfent Voice 404 475-2725 Computone Products FAX 404 343-9735 1100 Northmeadow Parkway Usenet ...!uunet!wotk!{nickh,root} Suite 150 Roswell, GA 30076
steve@taumet.com (Stephen Clamage) (07/31/90)
root@wotk.UUCP writes: >I'm curious why the following syntax was chosen for initializing an instance >of a class - >MyClass X(1,2,3,); >instead of the syntax used in C aggregate data types - >MyStruct X = {1,2,3}; The latter syntax says the first element gets 1, the second gets 2, etc. For an ordinary (non-class) aggregate type, this is still valid in C++. But there is no requirement that the parameters to a constructor bear any relationship whatever to the data members of a class. Using data-aggregate initialization syntax to call a function would seem to me to be confusing and non-intuitive. -- Steve Clamage, TauMetric Corp, steve@taumet.com