cpp:copy_constructors
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
cpp:copy_constructors [2018/05/07 07:06] – [Ορισμός ενός κατασκευαστή αντιγραφέα] gthanos | cpp:copy_constructors [2018/05/07 07:09] – [Ορισμός ενός κατασκευαστή αντιγραφέα] gthanos | ||
---|---|---|---|
Line 8: | Line 8: | ||
#include " | #include " | ||
- | void printArea(Rectangle r) { | + | void printArea(const Rectangle r) { |
cout << " area: " << r.getArea() << endl; | cout << " area: " << r.getArea() << endl; | ||
} | } | ||
Line 27: | Line 27: | ||
<code cpp> | <code cpp> | ||
- | Rectangle:: | + | Rectangle:: |
width = r.width; height = r.height; | width = r.width; height = r.height; | ||
} | } | ||
</ | </ | ||
- | Συνολικά η κλάση // | + | Η μεταβλητή //r// δηλώνεται ως //const// διότι κατά την εκτέλεση του κατασκευαστή το αντικείμενο //r// δεν θα μεταβληθεί. |
<code cpp Rectangle.cpp> | <code cpp Rectangle.cpp> |
cpp/copy_constructors.txt · Last modified: 2022/05/12 19:41 by gthanos