cpp:object_creation
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:object_creation [2020/04/08 10:55] – [Δημιουργία αντικειμένων] gthanos | cpp:object_creation [2020/04/08 13:56] – [Εναλλακτικοί τρόποι κλήσης του κατασκευαστή της κλάσης] gthanos | ||
---|---|---|---|
Line 84: | Line 84: | ||
<code c++ RectangleInitialization.cpp> | <code c++ RectangleInitialization.cpp> | ||
int main () { | int main () { | ||
- | Rectangle rect = {5,6}; // calls Rectangle(int w, int h) | + | Rectangle rect = {5, |
- | Rectangle rects[2] = {{4,5}, {5,6}}; // calls Rectangle(int w, int h) for each table element | + | Rectangle rects[2] = {{4,5}, {5,6}}; // καλεί |
cout << " | cout << " | ||
cout << " | cout << " | ||
Line 93: | Line 93: | ||
</ | </ | ||
- | Οι παραπάνω | + | Οι παραπάνω τρόποι είναι ισοδύναμοι εάν πρόκειται να αρχικοποιήσουμε ένα μεμονομένο αντικείμενο. Στην περίπτωση που θέλουμε να αρχικοποιήσουμε πίνακες από αντικείμενα, |
cpp/object_creation.txt · Last modified: 2021/05/07 06:22 (external edit)