User Tools

Site Tools


cpp:object_creation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
cpp:object_creation [2020/04/08 10:55] – [Δημιουργία αντικειμένων] gthanoscpp:object_creation [2020/04/08 13:55] – [Εναλλακτικοί τρόποι κλήσης του κατασκευαστή της κλάσης] 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,6};              // καλεί Rectangle(int w, int h) 
-  Rectangle rects[2] = {{4,5}, {5,6}}; // calls Rectangle(int w, int h) for each table element+  Rectangle rects[2] = {{4,5}, {5,6}}; // καλεί Rectangle(int w, int h) για κάθε θέση του πίνακα
   cout << "[rect    ] area: " << rect.getWidth() * rect.getHeight() << endl;   cout << "[rect    ] area: " << rect.getWidth() * rect.getHeight() << endl;
   cout << "[rects[0]] area: " << rects[0].getWidth() * rects[0].getHeight() << endl;   cout << "[rects[0]] area: " << rects[0].getWidth() * rects[0].getHeight() << endl;
cpp/object_creation.txt · Last modified: 2021/05/07 06:22 (external edit)