diff options
sem 11
1 files changed, 34 insertions, 0 deletions
| -rw-r--r-- | Sem. 11/Examples/Student/Student.cpp | 34 |
diff --git a/Sem. 11/Examples/Student/Student.cpp b/Sem. 11/Examples/Student/Student.cpp new file mode 100644 index 0000000..8b5b04c --- /dev/null +++ b/Sem. 11/Examples/Student/Student.cpp @@ -0,0 +1,34 @@ +#include "Student.h" + +Student::Student(const char* name, int age, size_t fn) : Person(name, age) +{ + setFn(fn); +} + +size_t Student::getFn() const +{ + return fn; +} + +void Student::setFn(size_t fn) +{ + + if (fn < 100) + fn = 100; + this->fn = fn; +} + +// The compiler will make: + +//Student(const Student& other) : Person(other), fn(other.fn), grade(other.grade) OK!!! +//{} + +//Student& operator=(const Student& other) OK!!!! +//{ +// if (this != &other) +// { +// Person::operator=(other); //handles the deletion and copying of the base class +// fn = other.fn; +// } +// return *this; +//}
\ No newline at end of file |
