diff options
| author | Syndamia <kamen@syndamia.com> | 2024-03-07 17:18:24 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2024-03-07 17:18:24 +0200 |
| commit | 449d0043523f13b4fd273e381b192b6fe10baefd (patch) | |
| tree | 81de2f9762aacc3331ccdf70956ebceb3b432da4 /week03/Exercise3.cpp | |
| parent | 83474fef7d7b495502db0c0a22665f43739dd8b9 (diff) | |
| download | oop-2023-solutions-449d0043523f13b4fd273e381b192b6fe10baefd.tar oop-2023-solutions-449d0043523f13b4fd273e381b192b6fe10baefd.tar.gz oop-2023-solutions-449d0043523f13b4fd273e381b192b6fe10baefd.zip | |
[w3] Added solutions for revision exercises
Diffstat (limited to 'week03/Exercise3.cpp')
| -rw-r--r-- | week03/Exercise3.cpp | 34 |
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"); +} |
