using UnityEngine;
using System.Collections;
public class chap8 : MonoBehaviour {
abstract class Animal{
protected string name;
public Animal(string name){
this.name = name;
}
//protected string GetInfo(){return "Animail:name=" + name;} error
public string GetInfo(){return "Animal:name=" + name;}
public abstract void Cry();
}
class Tiger:Animal{
public Tiger(string name):base(name){}
public override void Cry() { Debug.Log("Tiger Cry");}
}
// Use this for initialization
void Start () {
Tiger t1 = new Tiger("HODORI");
t1.Cry();
print (t1.GetInfo());
}
// Update is called once per frame
void Update () {
}
}












'Computer Language > 유니티' 카테고리의 다른 글
using 사용법 (0) | 2014.05.16 |
---|---|
배열 선언 (0) | 2014.05.16 |
로그 찍기 (0) | 2014.05.13 |
문자열 거꾸로 찍기 (0) | 2014.05.13 |
확장 클래스 (0) | 2014.05.13 |