comp.lang.ada
 help / color / mirror / Atom feed
* variant record and pointer
@ 2003-05-02 17:25 Noivet
  2003-05-02 17:44 ` Robert A Duff
  2003-05-02 19:00 ` Frank J. Lhota
  0 siblings, 2 replies; 3+ messages in thread
From: Noivet @ 2003-05-02 17:25 UTC (permalink / 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!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-02 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02 17:25 variant record and pointer Noivet
2003-05-02 17:44 ` Robert A Duff
2003-05-02 19:00 ` Frank J. Lhota

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox