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 15:57] – [Φιλικές Κλάσεις] gthanos | ||
---|---|---|---|
Line 84: | Line 84: | ||
class Cuboid { | class Cuboid { | ||
- | Rectangle | + | Rectangle |
int length; | int length; | ||
public: | public: | ||
- | | + | |
- | r.width += dw; | + | int volume(); |
- | | + | |
- | length += dl; | + | |
- | } | + | |
} | } | ||
- | < | + | |
+ | Cuboid:: | ||
+ | rect = r; length = l; | ||
+ | } | ||
+ | |||
+ | int Cuboid:: | ||
+ | return r.width * r.height * length; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | <code cpp CuboidUsage.cpp> | ||
+ | #include < | ||
+ | |||
+ | int main() { | ||
+ | Rectangle rectangle(5, | ||
+ | Cuboid cuboid(r, 10); | ||
+ | cout << " | ||
+ | } | ||
+ | </code> |
cpp/friend_methods.txt · Last modified: 2021/05/18 06:21 (external edit)