David Blume commited on 2017-12-30 14:10:49
Showing 4 changed files, with 14 additions and 2 deletions.
... | ... |
@@ -3,14 +3,19 @@ |
3 | 3 |
|
4 | 4 |
#define MY_LIB_DEFINE 0 |
5 | 5 |
|
6 |
+namespace MY_LIB { |
|
7 |
+ |
|
6 | 8 |
class my_lib_rect { |
7 | 9 |
int width_, height_; |
8 | 10 |
public: |
9 | 11 |
my_lib_rect(int width, int height); |
10 |
- int area() const; |
|
12 |
+ |
|
13 |
+ virtual int area() const; |
|
11 | 14 |
}; |
12 | 15 |
|
13 | 16 |
int my_lib_fn(); |
14 | 17 |
int my_lib_fn(int x); |
15 | 18 |
|
19 |
+} |
|
20 |
+ |
|
16 | 21 |
#endif |
... | ... |
@@ -12,6 +12,8 @@ namespace { |
12 | 12 |
|
13 | 13 |
} |
14 | 14 |
|
15 |
+namespace MY_LIB { |
|
16 |
+ |
|
15 | 17 |
my_lib_rect::my_lib_rect(int width, int height): |
16 | 18 |
width_(width), |
17 | 19 |
height_(height) |
... | ... |
@@ -32,3 +34,5 @@ int my_lib_fn(int x) { |
32 | 34 |
cout << "The function " << __PRETTY_FUNCTION__ << " with parameter " << x << " was called." << endl; |
33 | 35 |
return x + a; |
34 | 36 |
} |
37 |
+ |
|
38 |
+} |
... | ... |
@@ -14,6 +14,7 @@ |
14 | 14 |
#include "deadlock/deadlock.hpp" |
15 | 15 |
|
16 | 16 |
using namespace std; |
17 |
+using namespace MY_LIB; |
|
17 | 18 |
|
18 | 19 |
int length_of_array; |
19 | 20 |
|
... | ... |
@@ -89,6 +90,8 @@ int main() { |
89 | 90 |
cout << "sizeof(int) is " << sizeof(int) << "." << endl; |
90 | 91 |
my_lib_fn(); |
91 | 92 |
my_lib_fn(5); |
93 |
+ my_lib_rect r(16, 9); |
|
94 |
+ cout << "area of rect r is " << r.area() << "." << endl; |
|
92 | 95 |
test_cpp14(); |
93 | 96 |
|
94 | 97 |
{ |
95 | 98 |