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
Don't understand this section of code.
Don't understand this section of code.
Jan 31, 2010 at 2:09am UTC
EvanEjk
(27)
What does this code do?
1
2
3
4
Rectangle::Rectangle(): itsWidth(5), itsLength(10) {}
"Rectangle" is a class name. "Rectangle()" is a member function. "itsWidth" and "itsLength" are private member variables.
Thanks.
Last edited on
Jan 31, 2010 at 2:09am UTC
Jan 31, 2010 at 2:34am UTC
helios
(17574)
It explicitly calls the members' constructors and passes them those parameters. In this case, assuming the members are of basic types, it initializes itsWidth to 5 and itsLength to 10.
Jan 31, 2010 at 4:52am UTC
blackcoder41
(1426)
http://cplusplus.com/doc/tutorial/classes/
Topic archived. No new replies allowed.