-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (47 loc) · 1.04 KB
/
main.cpp
File metadata and controls
50 lines (47 loc) · 1.04 KB
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
#include <iostream>
#include <sstream>
using namespace std;
class LabelGenerator
{
private:
string prefix;
int count;
public:
LabelGenerator(string prefix , int count)
{
this -> prefix = prefix;
this -> count = count;
}
string nextLabel()
{
stringstream s;
s << count++;
string counter = s.str();
return prefix + counter;
}
};
int main()
{
LabelGenerator figureNumbers("Figure ", 1);
LabelGenerator pointNumbers("P", 0);
cout << "Figure numbers: ";
for (int i = 0; i < 3; i++)
{
if (i > 0) cout << ", ";
cout << figureNumbers.nextLabel();
}
cout << endl << "Point numbers: ";
for (int i = 0; i < 5; i++)
{
if (i > 0) cout << ", ";
cout << pointNumbers.nextLabel();
}
cout << endl << "More figures: ";
for (int i = 0; i < 3; i++)
{
if (i > 0) cout << ", ";
cout << figureNumbers.nextLabel();
}
cout << endl;
return 0;
}