Commit 307a647f53e99e512022158541d3bb382472bb6f
1 parent
bc4d0f58
Updated Koenig lookup example
Showing
2 changed files
with
25 additions
and
1 deletions
examples06/01-operator/koenig.cpp
0 → 100644
1 | +#include <iostream> | ||
2 | +#include <string> | ||
3 | + | ||
4 | +namespace Chrono { | ||
5 | +class Date { /* ... */ | ||
6 | +}; | ||
7 | +bool operator==(const Date &, const std::string &); | ||
8 | +std::string format(const Date &); // make string representation | ||
9 | +// ... | ||
10 | +} // namespace Chrono | ||
11 | + | ||
12 | + | ||
13 | +void f(Chrono::Date d, std::string s) { | ||
14 | + if (d == s) { | ||
15 | + // ... | ||
16 | + } else if (d == "August 4, 1914") { | ||
17 | + // ... | ||
18 | + } | ||
19 | +} |
examples06/01-operator/makefile
1 | +all: operator koenig.o | ||
2 | + | ||
1 | operator: operator.cpp | 3 | operator: operator.cpp |
2 | g++ -g -Wall -pedantic $^ -o $@ | 4 | g++ -g -Wall -pedantic $^ -o $@ |
3 | 5 | ||
6 | +koenig.o: koenig.cpp | ||
7 | + g++ -c -g -Wall -pedantic $^ -o $@ | ||
8 | + | ||
4 | .PHONY: clean | 9 | .PHONY: clean |
5 | 10 | ||
6 | clean: | 11 | clean: |
7 | - -rm operator | 12 | + -rm operator koenig.o |