当前位置:网站首页>C#中的继承关系

C#中的继承关系

2022-06-09 20:25:00 charlsdm

C#中继承关系

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

class Father
{
    

    //public Father()
    //{
    

    //}

    public Father(int i)
    {
    
        Debug.Log("Father构造");
    }
}

class Son:Father
{
    
    public Son(int i):base(i)
    {
    
        Debug.Log("Son的一个参数的构造");

    }

    public Son(int i,string str):this(i)
    {
    
        Debug.Log("Son的两个参数的构造");
    }

}


public class Fathers : MonoBehaviour
{
    
    // Start is called before the first frame update
    void Start()
    {
    
        Son myson = new Son(12, "hello");
    }

    // Update is called once per frame
    void Update()
    {
    
        
    }
}
原网站

版权声明
本文为[charlsdm]所创,转载请带上原文链接,感谢
https://blog.csdn.net/charlsdm/article/details/125062124