Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit82950a6d51e5462bd4d3d50b4cfd9faab2112987 (patch)
Author
 Angel Dimitriev <angel_dimitriev@abv.bg>
2022-05-07 18:25:42 +0300
Committer
 GitHub <noreply@github.com>
2022-05-07 18:25:42 +0300
Files39abf0d774c41d706e21dc9df6898e0fad3154f1
Object-oriented_programming_FMI-82950a6d51e5462bd4d3d50b4cfd9faab2112987.tar
Object-oriented_programming_FMI-82950a6d51e5462bd4d3d50b4cfd9faab2112987.tar.gz
Object-oriented_programming_FMI-82950a6d51e5462bd4d3d50b4cfd9faab2112987.zip
Parent82efd14cbeffddcc830bfecbb8a6c85434e2d1b1 (diff)
Create BigFour.cpp
1 files changed, 89 insertions, 0 deletions
-rw-r--r--Utills/BigFour.cpp89
diff --git a/Utills/BigFour.cpp b/Utills/BigFour.cpp
new file mode 100644
index 0000000..383440d
--- /dev/null
+++ b/Utills/BigFour.cpp
@@ -0,0 +1,89 @@
+
+#include <iostream>
+#include <cstring>
+
+using namespace std;
+
+class Student
+{
+ char* name;
+ int* grades;
+ size_t gradesSize;
+
+ void free()
+ {
+ delete[] name, grades;
+ }
+
+ void copyFrom(const Student& other)
+ {
+ setName(other.name);
+ setGrades(other.grades);
+ }
+
+ public:
+
+ Student() : name(nullptr), grades(nullptr) {}
+
+ Student(const Student& other)
+ {
+ copyFrom(other);
+ }
+
+ Student& operator=(const Student& other)
+ {
+ if (this != &other)
+ {
+ free();
+ copyFrom(other);
+ }
+ return *this;
+ }
+
+ ~Student()
+ {
+ free();
+ }
+
+ const char* getName() const
+ {
+ return name;
+ }
+
+ const int* getGrades() const
+ {
+ return grades;
+ }
+
+ void setName(const char* givenName)
+ {
+ if(givenName == nullptr || givenName == name)
+ return;
+ delete[] name;
+ name = new char[strlen(givenName) + 1];
+ strcpy(name, givenName);
+ }
+
+ void setGrades(const int* givenGrades, size_t size)
+ {
+ if(givenGrades == nullptr || givenGrades == grades)
+ return;
+
+ delete[] grades;
+
+ grades = new int[size];
+ for(size_t i = 0; i< size; i++)
+ grades[i] = givenGrades[i];
+ gradesSize = size;
+ }
+
+
+};
+
+int main()
+{
+
+
+ return 0;
+}
+