File: tobject2.pp

package info (click to toggle)
fpc 2.6.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 178,760 kB
  • ctags: 83,946
  • sloc: pascal: 2,000,374; xml: 138,807; ansic: 9,617; asm: 7,843; yacc: 3,747; php: 3,271; sh: 2,626; makefile: 2,610; lex: 2,537; sql: 267; cpp: 145; sed: 132; perl: 126; csh: 34; tcl: 7
file content (100 lines) | stat: -rw-r--r-- 1,479 bytes parent folder | download | duplicates (13)
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


TYPE

  psimpleobject = ^tsimpleobject;
  tsimpleobject = object
   x: longint;
   z: array[0..34] of byte;
   Procedure Init(somez: longint);
   Procedure Hello;
  end;

  pbase = ^tbase;
  tbase = object
   numofentries : longint;
   constructor init(i : integer);
   destructor done; virtual;
   procedure showit; virtual;
  end;

  pderived = ^tderived;
  tderived = object(tbase)
   x: longint;
   constructor init;
   destructor done; virtual;
   procedure showit; virtual;
  end;


  Procedure TsimpleObject.init(somez: longint);
  var
     i: byte;
  Begin
     for i:=0 to 34 do
      z[i]:=i;
     x:=somez;
  end;


  Procedure TSimpleObject.hello;
  var
   i: byte;
  Begin
   WriteLn('hello world');
   for i:=0 to 34 do
     Write(z[i],' ');
     WriteLn;
     WriteLN(x);
  end;


  constructor tbase.init(i: integer);
  Begin
   numofentries := i;
  end;

  destructor tbase.done;
  Begin
  end;

  procedure tbase.showit;
  Begin
    WriteLn('This is the base class');
  end;

  constructor tderived.init;
  Begin
   inherited init(5);
   x:=10;
  end;

  procedure tderived.showit;
  Begin
   WriteLn('This is the derived class');
   WriteLn(numofentries);
   WriteLn(x);
  end;

  destructor tderived.done;
  Begin
  end;


  Procedure CreateObject;
  var
   obj: pbase;
  Begin
    obj^.showit;
    dispose(obj,done);
  end;

var
 myobj: tsimpleobject;
 obj: pbase;
 devobj: tderived;
Begin
 obj:=new(pbase,init(10));
 obj^.showit;
 dispose(obj,done);
end.