comp.lang.ada
 help / color / mirror / Atom feed
* problems with classes
@ 2004-09-30 21:20 Rick Santa-Cruz
  2004-10-01  7:35 ` Dmitry A. Kazakov
  2004-10-01  7:58 ` Martin Krischik
  0 siblings, 2 replies; 6+ messages in thread
From: Rick Santa-Cruz @ 2004-09-30 21:20 UTC (permalink / raw)


Hi,

First of all I wanna thank all people in this group for the help. I am just 
a beginner in Ada and before I started Ada, I thought that cause I know C++ 
very well, it would be easy for me to understand Ada (in fact I made this 
experience with learning programmin languages like Java, Perl, C#, etc. 
after working a lot with C++). But this assumption was totally wrong. The 
syntax of Ada seems to me a bit strange, at least at the moment ;), but I am 
working hard to become better in Ada...

Here are 2 examples of source-codes:
1. Source1:
package Source_1 is
    type Parent_Class is tagged
        record
            Number: Integer;
        end record;
    type Child_Class is new Parent_Class with private;

    procedure Parent_Proc(P: Parent_Class);
    procedure Child_Proc(C: Child_Class);

    private
        type Child_Class is new Parent_Class with
            record
                Number2: Integer;
            end record;
end Source_1;
---------------------------------------------------------------------
1. Source2:
package Source_2 is
    type Parent_Class is tagged
        record
            Number: Integer;
        end record;
    type Child_Class is new Parent_Class with
            record
                Number2: Integer;
            end record;

    procedure Parent_Proc(P: Parent_Class);
    procedure Child_Proc(C: Child_Class);
end Source_2;

My question is now, why in the seconde code-example I get an error, that 
Parent_Class has to be declared ready, before I define the Child_Class? Why 
I don't get this error in the first case, cause there I specify the 
Child_Class with: "type Child_Class is new Parent_Class with private;", 
before I declare the procedure of the class Parent_Class?
If this would be C++, I think I would know the answer... so in C++ 
"something like this" exists, too. It is called pre-definition of a type. 
That means that, for example if I need the name of a type before I wanna 
specify it, I can just write:
class MyType;
and specify it later. Is this the case in Ada too?

Thanks in advance,
Rick 





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

end of thread, other threads:[~2004-10-04 10:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-30 21:20 problems with classes Rick Santa-Cruz
2004-10-01  7:35 ` Dmitry A. Kazakov
2004-10-01 18:41   ` Rick Santa-Cruz
2004-10-04  8:33     ` Dmitry A. Kazakov
2004-10-04 10:19       ` Martin Dowie
2004-10-01  7:58 ` Martin Krischik

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