C# 继承的传递性

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1302_继承的传递性
{
    class Grandpapa
    {
        internal string house = "天平一号楼";
    }
    class Father : Grandpapa
    {
        protected string car = "大众CC";

    }
    class Son : Father
    {
        private string wife = "老婆";
        public void ShowRiches()
        {
            Console.WriteLine("我的财产有:爷爷的{0},父亲的{1},我的{2}", house, car, wife);

        }

    }

    class Program
    {
        public static void Main(string[] args)
        {
            Son me = new Son();
            me.ShowRiches();
            Console.ReadLine();
        }
    }
}

//继承模式:1:n(映射)

 

你可能感兴趣的:(后端,C#)