-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
74 lines (64 loc) · 1.71 KB
/
main.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <string>
#include <locale>
using namespace std;
/*
Crie a classe Pessoa que tenha 03 construtores sobrecarregados
O primeiro construtor deve receber o nome, idade, email e telefone da pessoa;
O segundo construtor deve receber nome, idade e e-mail da pessoa;
O terceiro é o construtor padrão;
Crie um método para mostrar as informações; e. Crie 03 objetos, um para cada construtor.
*/
void corte() {
int width = 50;
string line(width, '=');
cout << line << endl;
}
class Pessoa {
private:
string nome;
int idade;
string email;
string telefone;
public:
Pessoa(string n, int i, string e, string t) {
nome = n;
idade = i;
email = e;
telefone = t;
}
Pessoa(string n, int i, string e) {
nome = n;
idade = i;
email = e;
}
Pessoa() {
nome = "";
idade = 0;
email = "";
telefone = "";
}
void mostrarInformacoes() {
cout << "Nome: " << nome << endl;
cout << "Idade: " << idade << endl;
cout << "Email: " << email << endl;
cout << "Telefone: " << telefone << endl;
}
};
int main() {
setlocale(LC_ALL, "portuguese");
corte();
Pessoa pessoa1("João", 25, "[email protected]", "(48)99912-3521");
Pessoa pessoa2("Mario", 30, "[email protected]");
Pessoa pessoa3;
cout << "Pessoa 1:" << endl;
pessoa1.mostrarInformacoes();
corte();
cout << "\nPessoa 2:" << endl;
pessoa2.mostrarInformacoes();
corte();
cout << "\nPessoa 3 (Construtor padrão):" << endl;
pessoa3.mostrarInformacoes();
corte();
return 0;
}