cpp:friend_methods
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:friend_methods [2017/04/20 15:51] – [Φιλικές Κλάσεις] gthanos | cpp:friend_methods [2017/04/20 16:09] – gthanos | ||
---|---|---|---|
Line 61: | Line 61: | ||
public: | public: | ||
Rectangle(int w, int h); | Rectangle(int w, int h); | ||
+ | Rectangle() {} | ||
void setWidth(int w); | void setWidth(int w); | ||
void setHeight(int h); | void setHeight(int h); | ||
Line 84: | Line 85: | ||
class Cuboid { | class Cuboid { | ||
- | Rectangle | + | Rectangle |
int length; | int length; | ||
public: | public: | ||
- | | + | |
- | r.width += dw; | + | int volume(); |
- | r.height | + | }; |
- | | + | |
- | | + | Cuboid:: |
+ | rect = r; length | ||
+ | } | ||
+ | |||
+ | int Cuboid:: | ||
+ | return rect.width * rect.height | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code cpp CuboidVolume.cpp> | ||
+ | #include < | ||
+ | using namespace std; | ||
+ | |||
+ | #include " | ||
+ | |||
+ | int main() { | ||
+ | | ||
+ | Cuboid cuboid(rectangle, | ||
+ | cout << " | ||
} | } | ||
</ | </ |
cpp/friend_methods.txt · Last modified: 2021/05/18 06:21 (external edit)