zoukankan      html  css  js  c++  java
  • 类的继承

    就一个":"  冒号。

    类的继承,主要目的是代码的重用。另外,通过类的继承,代码有清晰的组织关系。

    子类:父类   派生类:基类 

    看代码

    class Animal
        {
            public int weight;
            public int age;

            public Animal()
            {
                Console.WriteLine("动物 的构造方法");
            }
            public Animal(string n ,int w )
            {
                name = n; weight = w;
            }
            public void Sleep() { Console.WriteLine("动物睡觉"); }

            private string name;

            protected string Name
            {
                get { return name; }
                set { name = value; }
            }
        }

    上面的类是动物 基类

     class Wolf : Animal
        {
            public Wolf()
            {
                Console.WriteLine("狼 的构造方法");
            }
            public Wolf(string n, int w)
                : base(n,w)
            {            
                       
            }
            public void Eat()
            {

            }
        }
  • 相关阅读:
    折叠Collapse插件
    data按钮
    Web设计中打开新页面或页面跳转的方法 js跳转页面
    HTML文本框
    常用端口
    node.js(八) 有趣的东西才开始哦
    node.js(七) 子进程 child_process模块
    node.js(六) UTIL模块
    node.js(五)字符串转换
    SSL证书切换
  • 原文地址:https://www.cnblogs.com/imxh/p/2443322.html
Copyright © 2011-2022 走看看