Share Pastebin
Guest
Public paste!

Roin

By: a guest | Mar 20th, 2010 | Syntax: C++ | Size: 1.55 KB | Hits: 63 | Expires: Never
Copy text to clipboard
  1. //Basisklasse
  2.  
  3. class TKFZ {
  4.  
  5.         private:
  6.  
  7.                 String Typ, Hersteller;
  8.  
  9.                 float Preis;
  10.  
  11.         public:
  12.  
  13.         TKFZ();
  14.  
  15.         ~TKFZ();
  16.  
  17.         virtual void Create(String, String, float);
  18.  
  19.         virtual void Show(String &, String &, float &);
  20.  
  21. };
  22.  
  23. //Unterklasse
  24.  
  25. class TAuto : public TKFZ {
  26.  
  27.         private:
  28.  
  29.                 String Marke;
  30.  
  31.                 float Leistung;
  32.  
  33.         public:
  34.  
  35.                 virtual void Create(String, String, float, String, float);
  36.  
  37.                 virtual void Show (String &, String &, float &, String &, float &);
  38.  
  39.                 TAuto();
  40.  
  41.                 ~TAuto();
  42.  
  43. };
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. //implementierung
  54.  
  55. TKFZ::TKFZ() {
  56.  
  57.         Typ="Personenwagen";
  58.  
  59.         Hersteller= "VW";
  60.  
  61.         Preis= 20000;
  62.  
  63. }
  64.  
  65. TKFZ::~TKFZ() {
  66.  
  67. }
  68.  
  69. void TKFZ::Create(String t, String h, float p) {
  70.  
  71.         Typ=t;
  72.  
  73.         Hersteller=h;
  74.  
  75.         Preis=p;
  76.  
  77. }
  78.  
  79. void TKFZ::Show(String &t, String &h, float &p) {
  80.  
  81.         t=Typ;
  82.  
  83.         h=Hersteller;
  84.  
  85.         p=Preis;
  86.  
  87. }
  88.  
  89. void TAuto::Create(String T, String H, float P, String M, float L) {
  90.  
  91.         TKFZ::Create(T,H,P);
  92.  
  93.         Marke=M;
  94.  
  95.         Leistung=L;
  96.  
  97. }
  98.  
  99. void TAuto::Show (String &T, String &H, float &P, String &M, float &L) {
  100.  
  101.         TKFZ::Show(T,H,P);
  102.  
  103.         M=Marke;
  104.  
  105.         L=Leistung;
  106.  
  107. }
  108.  
  109. TAuto::TAuto() {
  110.  
  111.         Marke="Golf VI";
  112.  
  113.         Leistung= 108;
  114.  
  115. }
  116.  
  117. TAuto::~TAuto() {
  118.  
  119. }
  120.  
  121.  
  122. //instanz:
  123. TAuto *A;
  124.  
  125. //---------------------------------------------------------------------------
  126.  
  127. __fastcall TForm1::TForm1(TComponent* Owner)
  128.  
  129.         : TForm(Owner)
  130.  
  131. {
  132.  
  133.         A= new TAuto();
  134.  
  135. }
  136.  
  137. //Aufruf
  138. A->Create(Edit1->Text,Edit2->Text,Edit3->Text.ToDouble(), Edit4->Text, Edit5->Text.ToDouble());
  139. String T,H,M;
  140.  
  141.         float P,L;
  142.  
  143.         A->Show(T,H,P,M,L);