blob: 9d4a83430635e284f6238f9d060272880e237cfe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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");
}
|