From: Manu-CSS@gmx.de (Noivet)
Subject: variant record and pointer
Date: 2 May 2003 10:25:53 -0700
Date: 2003-05-02T17:25:55+00:00 [thread overview]
Message-ID: <67ac8b2c.0305020925.6c27576d@posting.google.com> (raw)
Hello!
Maybe you can help me. I need a pointer with variant record. I have
something like this:
-------
type object is (circle, square, triangle);
type node;
type pointer is access node;
type pointer (index: object) is record
ptr: pointer;
special: unbounded_string;
case index is
when circle => diameter: natural;
when square => side: natural;
when triangle => edge_1, edge_2, edge_3: natural;
end case;
end record;
-------
now I can declare:
s, t: pointer;
and then use it:
s := new node(circle);
t := new node(square);
s.diameter := 5;
t.side := 3;
s.side := 10; <------ and I wondered that the compiler compiled
successfully!
I expected a conflict, but there isn't.
is there something wrong with my declaration
of the pointer type? or can someone explain me that?
Thx!
next reply other threads:[~2003-05-02 17:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-02 17:25 Noivet [this message]
2003-05-02 17:44 ` variant record and pointer Robert A Duff
2003-05-02 19:00 ` Frank J. Lhota
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox