zoukankan      html  css  js  c++  java
  • 抽象类与抽象方法

    抽象类为基类:

    abstract class  Animal     {         string name;

            public string Name         {             get { return name; }             set { name = value; }         }         char gender;

            public char Gender         {             get { return gender; }             set { gender = value; }         }         int age;

            public int Age         {             get { return age; }             set { age = value; }         }         public Animal(string name, char gender, int age)         {             this.name = name;             this.gender = gender;             this.age = age;         }         public   abstract  void Shout();

        

    派生类(子类):

      class Cat:Animal
        {
            public Cat(string name, char gender, int age)
                : base(name, gender, age)
            {        
            }
            public   override void Shout()
            {
               Console . WriteLine("喵喵叫!");
            }

      class Dog:Animal
        {
            public Dog(string name, char gender, int age)
                : base(name, gender, age)
            {
            }
            public    override  void Shout()
            {
                Console.WriteLine("汪汪叫!");
            }
        }

    主方法:

     class Program     {         static void Main(string[] args)         {             Cat cat=new Cat ("加菲猫",'公',3);             cat.Shout();             Dog dog = new Dog("旺财", '母', 5);             dog.Shout();             Console.ReadKey();

            }     }

  • 相关阅读:
    some tips
    ORA00847: MEMORY_TARGET/MEMORY_MAX_TARGET and LOCK_SGA cannot be set together
    Chapter 01Overview of Oracle 9i Database Perfomrmance Tuning
    Chapter 02Diagnostic and Tuning Tools
    变量与常用符号
    Chapter 18Tuning the Operating System
    标准输入输出
    Trace files
    DBADeveloped Tools
    Chapter 03Database Configuration and IO Issues
  • 原文地址:https://www.cnblogs.com/hnzsb-vv1130/p/3849291.html
Copyright © 2011-2022 走看看