User Tools

Site Tools


cpp:stl:intro

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
cpp:stl:intro [2023/05/30 11:02]
gthanos [Η κλάση Student]
cpp:stl:intro [2023/05/30 18:30] (current)
gthanos [Η κλάση Student]
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::ostream& operator<<(std::ostream& out, const Student & st);   friend std::ostream& operator<<(std::ostream& out, const Student & st);
   bool operator>(const Student& st) const;   bool operator>(const Student& st) const;
Line 54: Line 60:
     delete []name;     delete []name;
   }   }
 +}
 +
 +char* Student::getName() const {
 +  return name;
 +}
 +
 +int Student::getAEM() const {
 +  return aem;
 +}
 +
 +void Student::setName(char* name) {
 +  this->name != nullptr;
 +  delete this->name;
 +  this->name = new char [strlen(name) + 1];
 +  strcpy(this->name, name);
 +}
 +
 +void Student::setAEM(int aem) {
 +  this->aem = aem;
 } }
  
cpp/stl/intro.txt · Last modified: 2023/05/30 18:30 by gthanos