Topic: 2 diff init syntaxes: = vs ()
Author: notbob@tessellation.com (Robert Allan Schwartz)
Date: 1997/02/11 Raw View
There are 2 different syntaxes for initializing something with one value:
(a) T x = y;
and
(b) T x(y);
assuming T is a type (possibly a class), and y is an expression (whose type
may or may not be T).
What's the difference?
A practical question: How do I know when I need syntax (a), and when I need
syntax (b)?
And a philosophical question: Why is there a difference at all?
Thanks,
Robert
-----------------------------------------------------------------------
Robert Allan Schwartz | voice (617) 499-9470 | Freelance instructor
955 Massachusetts Ave. #354 | fax (617) 868-8209 | of C, C++, OOAD, OODB
PO Box 9183 |
Cambridge, MA 02139 | email notbob@tessellation.com
URL http://www.tessellation.com/index.html
-----------------------------------------------------------------------
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: herbs@cntc.com (Herb Sutter)
Date: 1997/02/11 Raw View
notbob@tessellation.com (Robert Allan Schwartz) wrote:
>There are 2 different syntaxes for initializing something with one value:
Just a note, this article has already been extensively answered in
comp.lang.c++.moderated.
---
Herb Sutter (herbs@cntc.com)
Current Network Technologies Corp.
3100 Ridgeway, Suite 42, Mississauga ON Canada L5L 5M5
Tel 416-805-9088 Fax 905-608-2611
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]