-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 2.cpp
More file actions
53 lines (49 loc) · 861 Bytes
/
Copy pathproblem 2.cpp
File metadata and controls
53 lines (49 loc) · 861 Bytes
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
#include <iostream>
#include <string>
using namespace std;
class Person {
private:
static const int LIMIT = 25;
string lname; // Person’s last name
char fname[LIMIT]; // Person’s first name
public:
Person()
{
lname = "";
fname[0] = '\0';
}
Person(const string & ln, const char * fn = "Heyyou")
{
int length = strlen(fn);
if (length >= LIMIT)
{
length = LIMIT - 1;
}
for (int i = 0; i < length; i++)
{
fname[i] = fn[i];
}
fname[length] = '\0';
lname = ln;
}
void Show() const
{
cout << fname <<" "<<lname <<endl;
}
void FormalShow() const
{
cout << fname << ", " << lname<<endl;
}
};
void main()
{
Person one; // use default constructor
Person two("Smythecraft");
Person three("Dimwiddy", "Sam");
one.Show();
one.FormalShow();
two.Show();
two.FormalShow();
three.Show();
three.FormalShow();
}