-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.48.cpp
More file actions
40 lines (31 loc) · 747 Bytes
/
16.48.cpp
File metadata and controls
40 lines (31 loc) · 747 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
#include "debug_rep.h"
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
class Out {
friend std::ostream &operator<<(std::ostream &, const Out &);
public:
Out(const std::string &s = "") : text(s) {}
private:
std::string text;
};
std::ostream &operator<<(std::ostream &os, const Out &o) {
return os << o.text;
}
int main() {
Out obj("object");
cout << debug_rep(obj) << "\n\n";
int *vp = nullptr;
cout << debug_rep(vp) << "\n\n";
int i = 5, *ip = &i;
cout << debug_rep(ip) << "\n\n";
string s = "string";
cout << debug_rep(s) << "\n\n";
char ca1[] = "char array";
cout << debug_rep(ca1) << "\n\n";
const char ca2[] = "const char array";
cout << debug_rep(ca2) << endl;
return 0;
}