cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
initializer's list
initializer's list
Jun 25, 2008 at 4:25pm UTC
Bboy Champloo
(2)
what's the difference between:
1-
return type
function-name(): w(0), h(0) { //definition goes here }
2-
return type
function-name() { w(0); h(0) }
being w,h data members of a certain class, and the function a member function?
Jun 25, 2008 at 4:55pm UTC
Duthomhas
(13282)
The first directly initializes the object.
The second may or may not involve the use of a copy constructor (over which you have no control).
The function-name, BTW, must be a constructor.
Hope this helps.
Topic archived. No new replies allowed.