cpp:stl:intro
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cpp:stl:intro [2023/05/29 16:14] – gthanos | cpp:stl:intro [2023/05/30 18:30] (current) – [Η κλάση Student] gthanos | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| ===== Η κλάση Student ===== | ===== Η κλάση Student ===== | ||
| - | Στα παραδείγματα που ακολουθούν συχνά χρησιμοποιείται η παρακάτω κλάση Student. | + | Στα παραδείγματα που ακολουθούν |
| <code cpp Student.hpp> | <code cpp Student.hpp> | ||
| Line 16: | Line 16: | ||
| class Student { | class Student { | ||
| - | public: | + | private: |
| char *name; | char *name; | ||
| int aem; | int aem; | ||
| + | public: | ||
| Student(); | Student(); | ||
| Student(const char *name, int aem); | Student(const char *name, int aem); | ||
| Student(const Student& | Student(const Student& | ||
| ~Student(); | ~Student(); | ||
| + | | ||
| + | char* getName() const; | ||
| + | int getAEM() const; | ||
| + | void setName(char*); | ||
| + | void setAEM(int); | ||
| + | | ||
| friend std:: | friend std:: | ||
| bool operator> | bool operator> | ||
| + | bool operator< | ||
| Student& | Student& | ||
| }; | }; | ||
| Line 53: | Line 60: | ||
| delete []name; | delete []name; | ||
| } | } | ||
| + | } | ||
| + | |||
| + | char* Student:: | ||
| + | return name; | ||
| + | } | ||
| + | |||
| + | int Student:: | ||
| + | return aem; | ||
| + | } | ||
| + | |||
| + | void Student:: | ||
| + | this-> | ||
| + | delete this-> | ||
| + | this-> | ||
| + | strcpy(this-> | ||
| + | } | ||
| + | |||
| + | void Student:: | ||
| + | this-> | ||
| } | } | ||
| Line 73: | Line 99: | ||
| bool Student:: | bool Student:: | ||
| if(aem > st.aem) | if(aem > st.aem) | ||
| + | return true; | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | bool Student:: | ||
| + | if(aem < st.aem) | ||
| return true; | return true; | ||
| return false; | return false; | ||
cpp/stl/intro.1685376875.txt.gz · Last modified: 2023/05/29 16:14 by gthanos
