Le fichier source est ${UPS_HOME}/upssdk/demo/${UPS_LANGUAGE}/heritede.upl.
upscmp Source=heritede.upl
heritede
upssng Source=heritede.upl
Source Composant "Exemple d'héritages" Version 4.0.0;
Public :
/******/
Type TA
/*****/
Public :
A : Booleen;
B : Caractere;
Constructeur();
Procedure P1();
Procedure P2(P : Caractere);
Fin Type
Type TB HeriteDe TA
/*****************/
Public :
C : Entier;
D : Nul Ou Entier;
Constructeur();
Procedure P1();
Procedure P3(P : Caractere);
Fin Type
Type TC
/*****/
Public :
E : Reel;
F : Nul Ou Reel;
Constructeur();
Procedure P4();
Fin Type
Type TD HeriteDe TA, TC
/*********************/
Public :
G : Caractere;
Constructeur();
Procedure P4();
Fin Type
Constructeur TA()
/***************/
Debut
A=Vrai;
B="Objet TA";
Fin Constructeur
Procedure TA.P1()
/***************/
Debut
Ecran.Ecrire("TA.P1");
Fin Procedure
Procedure TA.P2(P : Caractere)
/**************************/
Debut
Ecran.Ecrire("TA.P2");
B=P;
Fin Procedure
Constructeur TB()
/***************/
Debut
C=10;
D=11;
Fin Constructeur
Procedure TB.P1()
/***************/
Debut
Ecran.Ecrire("TB.P1");
Fin Procedure
Procedure TB.P3(P : Caractere)
/**************************/
Debut
Ecran.Ecrire("TB.P3");
B=P;
Fin Procedure
Constructeur TC()
/***************/
Debut
E=10.2;
F=2.1;
Fin Constructeur
Procedure TC.P4()
/***************/
Debut
Ecran.Ecrire("TC.P4");
Fin Procedure
Constructeur TD()
/***************/
Debut
G="Objet TC";
Fin Constructeur
Procedure TD.P4()
/***************/
Debut
Ecran.Ecrire("TD.P4");
Fin Procedure
Principal
/*******/
Variable
VA : TA;
VB : TB;
VC : TC;
VD : TD;
Debut
Ecran.Ecrire(VA.B);
Ecran.Ecrire(VB.B);
Ecran.Ecrire(VC.E);
Ecran.Ecrire(VD.B);
Ecran.Ecrire(VD.E);
Ecran.Ecrire("\n");
VA.P1();
VA.P2("coucou");
Ecran.Ecrire(VA.B);
Ecran.Ecrire("\n");
VB.P1();
>
VB.P2("coucou");
Ecran.Ecrire(VB.B);
VB.P3("bonjour");
Ecran.Ecrire(VB.B);
VB.P1.Super();
Ecran.Ecrire("\n");
VC.P4();
Ecran.Ecrire("\n");
VD.P1();
VD.P2("hello");
Ecran.Ecrire(VD.B);
VD.P4();
VD.P4.Super();
Fin Principal