pborawski

C# konstruktory i dziedziczenie

Mar 12th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication7
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             //Zwierze z = new Zwierze();
  13.             Kot k = new Kot();
  14.             Console.WriteLine();
  15.             Console.ReadKey();
  16.         }
  17.     }
  18.     class Zwierze
  19.     {
  20.         public string gatunek;
  21.         public Zwierze()
  22.         {
  23.             gatunek = "nieznany";
  24.         }
  25.         public Zwierze(String gat)
  26.         {
  27.             gatunek = gat;
  28.         }
  29.  
  30.     }
  31.     class Kot : Zwierze
  32.     {
  33.      
  34.         public Kot() : base("Manx")
  35.         {
  36.             ;
  37.         }
  38.         public Kot() : this("Kociak")
  39.         {
  40.             ;                              
  41.         }                          
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment