User Tools

Site Tools


cpp:constructors

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:constructors [2020/04/14 07:34] gthanoscpp:constructors [2020/04/14 07:36] gthanos
Line 17: Line 17:
     int getHeight() const;     int getHeight() const;
 }; };
 +</code>
 +
 +<code cpp Rectangle.cpp>
 +#include "Rectangle.hpp"
  
 Rectangle::Rectangle(int w, int h) { Rectangle::Rectangle(int w, int h) {
   width = w; height = h;   width = w; height = h;
 } }
- 
 void Rectangle::setWidth(int w) { width = w; } void Rectangle::setWidth(int w) { width = w; }
 void Rectangle::setHeight(int h) { height = h; } void Rectangle::setHeight(int h) { height = h; }
Line 40: Line 43:
 <WRAP center round info 80%> <WRAP center round info 80%>
 Σε αναλογία με τις μεθόδους ο κατασκευαστής μπορεί να οριστεί εντός της κλάσης, όπως παρακάτω. Η δήλωση εντός της κλάσης συνεπάγεται τη δήλωση από τον προγραμματιστή του κατασκευαστή ως //inline//. Σε αναλογία με τις μεθόδους ο κατασκευαστής μπορεί να οριστεί εντός της κλάσης, όπως παρακάτω. Η δήλωση εντός της κλάσης συνεπάγεται τη δήλωση από τον προγραμματιστή του κατασκευαστή ως //inline//.
-<code c++ Rectangle.cpp>+<code cpp Rectangle.cpp>
 class Rectangle { class Rectangle {
   private:   private:
cpp/constructors.txt · Last modified: 2021/05/07 06:11 (external edit)