반응형
using System;
using System.Collections.Generic;
using System.Text;

namespace 추상클래스
{
    // C#에서는 추상클래스에만  추상 메쏘드를  선언 가능 !! 
     abstract class Person
    {
         public int age; 
         // abstract  -->  virtual !!
        public abstract void Die();// 순수 가상함수 !! 
        public void Work() { } 

    }
    class buddist : Person
    {
        public override void Die()
        { 
 
        }
    }   
   
    class Program
    {
        static void Main(string[] args)
        {
           // Person p = new Person();
           // p.Die();
        }
    }
}
//  추상 클래스와 인터페이스 !! 
// 같은점 
//    - 객체를 직접 생성 불가능 !! 
//    - sealed 키워드??  사용불가 !! 
// 다른점 !! 
// 1)  추상 클래스에는 일반적인 함수의 구현과 추상 메소드 둘다 가능하다 !
//    -> 인터페이스에는 가상함수  가능하다 !!  
// 2) 인터페이스는 기본으로 public이다 !!  
// 3) 인터페이시는 인터페이스만 상속이 가능하다 !! 





abstract class  Person 
{
    private int age; 
    private string name; 
    
    public  abstract void work(); 
}

interface IStudy
{
    void Study(); 
}

interface IEmp
{
    void GetPay(); 
}


class Pro  : Person  ,IEmp
{


public void  GetPay()
{
 	throw new NotImplementedException();
}

public override void  work()
{
 	throw new NotImplementedException();
}
}



class Student : Person , IStudy 
{


public void  Study()
{
 	throw new NotImplementedException();
}

public override void  work()
{
 	throw new NotImplementedException();
}
}


'C#' 카테고리의 다른 글

[C#] 필드멤버  (0) 2014.11.18
[C#] 인터페이스  (0) 2014.11.18
[C#] 인덱서  (0) 2014.11.18
[C#] 이벤트  (0) 2014.11.18
[C#] 예외처리  (0) 2014.11.18

+ Recent posts