- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_sample.cpp
More file actions
Latest commit
46 lines (36 loc) · 738 Bytes
/
Copy pathtemplate_sample.cpp
File metadata and controls
46 lines (36 loc) · 738 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
#include<iostream>
usingnamespacestd;
template <classdata_t>
classlist {
data_t data;
list *next;
public:
list(data_t d);
voidadd(list *node) { node->next = this; next = 0; }
list *getnext() { return next; }
data_tgetdata() { return data; }
};
template <classdata_t>
list<data_t>::list(data_t d)
{
data = d;
next = 0;
}
intmain(int argc, constchar * argv[]) {
list<char> start('a');
list<char> *p, *last;
int i;
last = &start;
for (i=0; i<26; i++) {
p = new list<char> ('a' + i);
p->add(last);
last = p;
}
p = &start;
while (p) {
cout << p->getdata();
p = p->getnext();
}
cout << "\n";
return0;
}