aboutsummaryrefslogtreecommitdiff
path: root/week03/Exercise3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'week03/Exercise3.cpp')
-rw-r--r--week03/Exercise3.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/week03/Exercise3.cpp b/week03/Exercise3.cpp
new file mode 100644
index 0000000..9d4a834
--- /dev/null
+++ b/week03/Exercise3.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <cstring>
+
+struct Person {
+private:
+ char* firstName;
+ char* lastName;
+ unsigned int age;
+ char* email;
+
+public:
+ Person(const char* firstName, const char* lastName, unsigned int age, const char* email) {
+ this->firstName = new char[strlen(firstName)];
+ strcpy(this->firstName, firstName);
+
+ this->lastName = new char[strlen(lastName)];
+ strcpy(this->lastName, lastName);
+
+ this->age = age;
+
+ this->email = new char[strlen(email)];
+ strcpy(this->email, email);
+ }
+
+ ~Person() {
+ delete[] firstName;
+ delete[] lastName;
+ delete[] email;
+ }
+};
+
+int main() {
+ Person p = Person("John", "Doe", 21, "john.doe@email.com");
+}