-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo9.cpp
77 lines (66 loc) · 1.04 KB
/
demo9.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <string>
using namespace std;
class Screen;
class Dog
{
public:
int goo(Screen& sc);
};
class Screen
{
public:
friend class Window_Mgr;
friend int calcArea(Screen &);
friend int Dog::goo(Screen&);
// friend int Dog::koo(Screen&);
typedef string::size_type index;
Screen(int ht=0, int wd=0): contents(ht*wd, ' '), cursor(0),height(ht),width(wd){}
int area() const
{ return height * width; }
private:
string contents;
index cursor;
int height, width;
};
class Window_Mgr
{
public:
void relocate(int r, int c, Screen& s)
{
s.height += r;
s.width += c;
}
};
/*
class Dog
{
public:
int foo(Screen& sc)
{
return sc.height * sc.width;
}
int koo(Screen& sc)
{
return sc.height * sc.width;
}
};
*/
int Dog::goo(Screen& sc)
{
return sc.height * sc.width;
}
int calcArea(Screen & screen)
{
return screen.height * screen.width;
}
int main()
{
Screen sc(30,50);
cout << sc.area() << endl;
cout << calcArea(sc) << endl;
Window_Mgr wm;
wm.relocate(20, 100, sc);
cout << calcArea(sc) << endl;
return 0;
}