This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | Previous revision Next revision Both sides next revision | ||
|
cpp:stl:student [2020/05/28 13:14] |
cpp:stl:student [2020/05/28 14:10] gthanos |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Student ====== | ||
| + | |||
| + | <code cpp Student.hpp> | ||
| + | #ifndef _STUDENT_HPP_ | ||
| + | #define _STUDENT_HPP_ | ||
| + | # | ||
| + | #include < | ||
| + | |||
| + | class Student { | ||
| + | public: | ||
| + | char *name; | ||
| + | int aem; | ||
| + | |||
| + | Student(); | ||
| + | Student(const char *name, int aem); | ||
| + | Student(const Student& | ||
| + | ~Student(); | ||
| + | friend std:: | ||
| + | bool operator> | ||
| + | Student& | ||
| + | }; | ||
| + | |||
| + | Student:: | ||
| + | this-> | ||
| + | strcpy(this-> | ||
| + | this-> | ||
| + | std::cerr << "Argu Construct : " << *this << std::endl; | ||
| + | } | ||
| + | |||
| + | Student:: | ||
| + | name = new char [strlen(st.name) + 1]; | ||
| + | strcpy(name, | ||
| + | aem = st.aem; | ||
| + | std::cerr << "Copy Construct : " << *this << std::endl; | ||
| + | } | ||
| + | |||
| + | Student:: | ||
| + | this-> | ||
| + | this-> | ||
| + | } | ||
| + | |||
| + | Student:: | ||
| + | if(name != nullptr) { | ||
| + | std::cerr << " | ||
| + | delete []name; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | Student& | ||
| + | if(name != nullptr) | ||
| + | delete name; | ||
| + | name = new char [strlen(st.name) + 1]; | ||
| + | strcpy(name, | ||
| + | aem = st.aem; | ||
| + | std::cerr << "Copy : " << *this << std::endl; | ||
| + | return *this; | ||
| + | } | ||
| + | |||
| + | std:: | ||
| + | if(st.name != nullptr) | ||
| + | out << st.name << " " << st.aem; | ||
| + | return out; | ||
| + | } | ||
| + | |||
| + | bool Student:: | ||
| + | if(aem > st.aem) | ||
| + | return true; | ||
| + | return false; | ||
| + | } | ||
| + | #endif | ||
| + | </ | ||