This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
cpp:this [2017/04/20 15:39] gthanos created |
cpp:this [2020/04/08 14:32] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Ο δείκτης this ====== | ||
| - | |||
| - | Κατά τον ορισμό συναρτήσεων της κλάσης θέλουμε συχνά να αναφερθούμε στο αντικείμενο καλεί τη συγκεκριμένη μέθοδο. Ο τελεστής μπορεί να έχει διάφορες χρήσεις, | ||
| - | |||
| - | <code cpp Rectangle.cpp> | ||
| - | #include < | ||
| - | using namespace std; | ||
| - | |||
| - | class Rectangle { | ||
| - | private: | ||
| - | int width, height; | ||
| - | public: | ||
| - | Rectangle(int width, int height); | ||
| - | void setWidth(int width); | ||
| - | void setHeight(int height); | ||
| - | int getWidth(); | ||
| - | int getHeight(); | ||
| - | }; | ||
| - | |||
| - | Rectangle:: | ||
| - | this-> | ||
| - | } | ||
| - | |||
| - | void Rectangle:: | ||
| - | void Rectangle:: | ||
| - | int Rectangle:: | ||
| - | int Rectangle:: | ||
| - | </ | ||
| - | |||
| - | |||