zoukankan      html  css  js  c++  java
  • 虚方法--重载

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace ConsoleApplication1
    {
       public class Vehicle
        {
            public float weight;
            public Vehicle(float w)
            {
                weight = w;
            }
            public virtual void show()
            {
                Console.WriteLine("The weight of Vehicle is:" + weight);
            }
        }
        public class Car:Vehicle
        {
            int passengers;
        public Car(float w,int p):base(w)
            {
                passengers = p;
            }
            public override void show()
            {
                base.show();
                Console.WriteLine("The passengers of Car is:" + passengers);
            }
        }
        class Test
        {
            static void Main(string[] args)
            {
                Car c = new Car(6, 100);
                c.show();
                Console.Read();
            }
        }
    }
  • 相关阅读:
    142. 环形链表 II
    59. 螺旋矩阵 II
    996. 正方形数组的数目
    1323. 6 和 9 组成的最大数字
    面试题 17.14. 最小K个数
    389. 找不同
    1103. 分糖果 II
    背景透明度
    css3-新属性-用户界面
    响应式布局-基础结构
  • 原文地址:https://www.cnblogs.com/wbwhy/p/11700534.html
Copyright © 2011-2022 走看看