-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.prg
103 lines (88 loc) · 1.88 KB
/
class.prg
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Testing class construction and access and interface calls
extern "C" procedure printf( const byte^ fmt ...);
interface Object
{
function x int() const nothrow;
function y int() const nothrow;
function ofs_x int( int addx) const nothrow;
function ofs_y int( int addy) const nothrow;
}
interface ObjectUpdater
{
operator = ( int x_, int y_) nothrow;
}
class Point :Object,ObjectUpdater
{
public constructor( int x_, int y_) nothrow
{
m_x = x_;
self.m_y = y_;
}
destructor
{
}
public operator = ( int x_, int y_) nothrow
{
self.m_x = x_;
m_y = y_;
}
public function x int() const nothrow
{
return m_x;
}
public function y int() const nothrow
{
return self.m_y;
}
function ofs_x int( int addx) const nothrow
{
return m_x + addx;
}
function ofs_y int( int addy) const nothrow
{
return m_y + addy;
}
public function object Object() const nothrow
{
return self.Object;
}
public function updater ObjectUpdater() nothrow
{
return self.ObjectUpdater;
}
int m_x;
int m_y;
}
class Line :Point
{
public constructor( int x_, int y_) nothrow
{
self.Point = {x_,y_};
}
public procedure move( int x_, int y_) nothrow
{
self.Point = {x_,y_};
}
}
main {
var float x = 1.23;
var Line ab = {7.23, 4.23};
var Object obj = ab.object();
printf("RESULT[1] x = %d\n", obj.x());
printf("RESULT[1] y = %d\n", obj.y());
var ObjectUpdater updater = ab.updater();
updater = {31,411};
printf("RESULT[2] x = %d\n", obj.x());
printf("RESULT[2] y = %d\n", obj.y());
updater = {71,511};
printf("RESULT[3] x = %d\n", obj.ofs_x( -13));
printf("RESULT[3] y = %d\n", obj.ofs_y( 1));
var ObjectUpdater updater2 = updater;
updater2 = {32,412};
printf("RESULT[4] x = %d\n", obj.ofs_x( -11));
printf("RESULT[4] y = %d\n", obj.y());
var Point const^ ptr = &ab;
printf("RESULT[5] ptr->x() = %d\n", ptr->x());
printf("RESULT[5] ptr->y() = %d\n", ptr->y());
return 0;
}