Article View: pl.comp.lang.pascal
Article #92607Re: [OT] No to ciekawostka
From: Andrzej Grażyński
Date: Wed, 10 Sep 2008 21:14
Date: Wed, 10 Sep 2008 21:14
83 lines
2345 bytes
2345 bytes
Spójrzcie na poniższy programik, potem powiedzcie, co powinno się
wypisać. A potem uruchomcie to w BP7 i zobaczcie, co się faktycznie
wypisuje. Uruchomcie w FP i porównajcie.
Gdzie jest błąd?
Type
PFIrstClass = ^TFIrstClass;
TFIrstClass = object
X: INteger;
Constructor init;
constructor init2;
destructor done;
procedure wypiszmnie;virtual;
end;
PSecondClass = ^TSecondClass;
TSecondClass = object(TFIrstClass)
procedure wypiszmnie;virtual;
end;
PThirdCLass = ^TThirdCLass;
TThirdCLass = object(TSecondClass)
Z: integer;
Constructor init;
procedure wypiszmnie;virtual;
end;
Constructor TFIrstClass.init;
begin
X := 1;
end;
Constructor TFIrstClass.init2;
begin
Self.init;
end;
destructor TFIrstClass.done;
begin
end;
Constructor TThirdClass.init;
begin
if not Inherited Init2
then
Fail;
Z := 1;
end;
procedure TFirstClass.wypiszmnie;
begin
Writeln('Pierwsza');
end;
procedure TSecondClass.wypiszmnie;
begin
Writeln('Druga');
end;
procedure TThirdClass.wypiszmnie;
begin
Writeln('Trzecia');
end;
var
P: PFirstClass;
begin
P := New(PThirdClass, Init);
P^.WypiszMnie;
Dispose(P, Done);
end.
Technical Details
Message-ID:
<ga9dbc$t6b$1@news.onet.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mailReferences:
<20080905121945.03f2cdf2.solaris@be.inspired>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail From: Andrzej Grażyński <grazynsk@petex.com.pl> Newsgroups: pl.comp.lang.pascal Subject: Re: [OT] No to ciekawostka Date: Wed, 10 Sep 2008 23:14:07 +0200 Organization: Onet.pl Lines: 84 Message-ID: <ga9dbc$t6b$1@news.onet.pl> References: <20080905121945.03f2cdf2.solaris@be.inspired> NNTP-Posting-Host: 83.1.77.84 Mime-Version: 1.0 X-Trace: news.onet.pl 1221081260 29899 83.1.77.84 (10 Sep 2008 21:14:20 GMT) X-Complaints-To: usenet@news.onet.pl NNTP-Posting-Date: Wed, 10 Sep 2008 21:14:20 +0000 (UTC) X-Sender: 2ysppuKZfnIJFd8Xm5/5BA== In-Reply-To: <20080905121945.03f2cdf2.solaris@be.inspired> User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit