C# - abstract 추상화
자세한 설명은 Microsoft 설명 링크
C++은 함수를 순수함수로 만들때 =0을 하면 되지만 C#은 안됨. abstract 써야함.
샘플 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | abstract class ShapesClass { abstract public int Area(); } class Square : ShapesClass { int side = 0; public Square(int n) { side = n; } // Area method is required to avoid // a compile-time error. public override int Area() { return side * side; } static void Main() { Square sq = new Square(12); Console.WriteLine("Area of the square = {0}", sq.Area()); } interface I { void M(); } abstract class C : I { public abstract void M(); } } // Output: Area of the square = 144 | cs |
반응형
'Programming > C/C++/C#' 카테고리의 다른 글
C++ - 프로퍼티 get set (0) | 2016.07.13 |
---|---|
asm - 어셈블리어 기초2 (4) | 2016.04.13 |
asm - 어셈블리어 기초 (1) | 2016.04.09 |
C++ - 비트 출력 해보기 (1) | 2016.03.09 |
C# - Exception - PInvokeStackImbalance (3) | 2016.01.20 |
C# - 파일 존재 여부 확인방법 (0) | 2015.12.24 |
C++ - 연산자 operator (0) | 2015.12.16 |
C++ - 포인터를 이용해 배열 만들기 (0) | 2015.12.01 |