-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrtref.cpp
More file actions
39 lines (34 loc) · 791 Bytes
/
strtref.cpp
File metadata and controls
39 lines (34 loc) · 791 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
// strtref.cpp -- using structure references
#include <iostream>
using namespace std;
struct sysop
{
char name[26];
char quote[64];
int used;
};
const sysop & use(sysop & sysopref); // function with a reference return type
int main ()
{
sysop looper =
{
"Rick \"Fortran\" Looper",
"I'm a goto kind of guy",
0
};
use(looper); // looper is type sysop
cout << "Looper: " << looper.used << " use(s)\n";
sysop copycat;
copycat = use(looper);
cout << "Looper: " << looper.used << " use(s)\n";
cout << "Copycat: " << copycat.used << " use(s)\n";
cout << "use(looper): " << use(looper).used << " use(s)\n";
return 0;
}
const sysop & use(sysop & sysopref)
{
cout << sysopref.name << " says:\n";
cout << sysopref.quote << endl;
sysopref.used++;
return sysopref;
}