[C#]기본상속 vitual override
페이지 정보
작성자 sbLAB 댓글 0건 조회 4,445회 작성일 18-07-25 17:28본문
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
ntop nt = new ntop();
nt.run1();
nt.show();
Console.ReadKey();
}
}
//부모클래스
class top
{
//virtual 을 선언하여 자식클래스에서 overiding 가능함을 알려줌
virtual public void run1()
{
Console.WriteLine("run1 입니다!");
}
}
//자식클래스(부모상속)
class ntop : top
{
//virtual - override
public override void run1()
{
Console.WriteLine("ntop run1 입니다!");
}
public void show()
{
Console.WriteLine("ntop show 입니다!");
}
}
}
댓글목록
등록된 댓글이 없습니다.