Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_CSharp/CSharp_Inheritance.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

5.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
csharp-inheritance C# Inheritance Programming_Language draft conceptual
derived base class C#
sealed keyword C#
C# 상속
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
oop
inheritance
https://www.w3schools.com/cs/cs_inheritance.php

CSharp Inheritance

🎯 한 줄 통찰 (One-line insight)

C#'s inheritance syntax class Car : Vehicle OMITS the access specifier that C++'s equivalent class Car : public Vehicle REQUIRES — C# never lets you write class Car : private Vehicle, because member-level access (public/private/protected on each field/method) is the only lever C# offers, unlike C++ which layers an ADDITIONAL access specifier onto the inheritance relationship itself; and where C++ uses final to block further subclassing, C# uses a differently-named but functionally identical sealed keyword. [S1]

🧠 핵심 개념 (Core concepts)

  • Derived class (child) — the class that inherits from another class. [S1]
  • Base class (parent) — the class being inherited from. [S1]
  • : syntaxclass Car : Vehicle — no access specifier before the base class name, unlike C++'s class Car : public Vehicle. [S1]
  • Inherited members — a derived class gains ALL fields and methods from its base class, callable/accessible directly on the derived class's own objects. [S1]
  • Motivation — code reusability: reuse an existing class's fields/methods instead of rewriting them in the new class. [S1]
  • sealed keyword — prevents a class from being inherited at all; attempting to derive from a sealed class is a compile error ('Car': cannot derive from sealed type 'Vehicle'). [S1]

📖 세부 내용 (Details)

  • Full example: class Vehicle { public string brand = "Ford"; public void honk() { Console.WriteLine("Tuut, tuut!"); } } class Car : Vehicle { public string modelName = "Mustang"; } ... Car myCar = new Car(); myCar.honk(); Console.WriteLine(myCar.brand + " " + myCar.modelName); → calls the PARENT's honk() and reads the PARENT's brand field directly on a Car object, alongside Car's own modelName. [S1]
  • Sealed class blocking inheritance: sealed class Vehicle { ... } class Car : Vehicle { ... } → compile error. [S1]
  • The tutorial explicitly points forward to Polymorphism as building on inherited methods to perform different tasks. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 상속 문법에 접근 지정자가 없음: C++는 class Car : public Vehicle처럼 상속 관계 자체에 public/private/protected 접근 지정자를 붙여야 했지만, C#은 class Car : Vehicle처럼 이 지정자 없이 상속하며, 접근 제어는 오직 멤버 단위(각 필드/메서드의 public/private/protected)로만 이뤄진다는 점이 확인됨. [S1]
  • final 대신 sealed라는 다른 이름의 동일 개념: C++11의 final 키워드와 동일한 역할(더 이상 상속 불가)을 C#은 sealed라는 이름으로 제공한다는 점이 확인됨 — 개념은 같지만 키워드가 다름. [S1]
  • 원문 구조상 상속이 단일 챕터로 압축됨: Topic_CPP는 Inheritance/Access/Multilevel/Multiple을 4개 문서로 나눴지만, C# 사이드바는 cs_inheritance.php 단 하나로 기본 상속과 sealed를 모두 다룬다는 점이 확인됨 — 다단계·다중 상속에 대한 별도 챕터가 C# 튜토리얼에는 없음. [S1]

🛠️ 적용 사례 (Applied in summary)

Vehicle(부모)의 brand 필드와 honk() 메서드를 Car(자식)가 상속받아 Car 객체에서 그대로 사용하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Inheritance without an access specifier on the base class (C#):

class Vehicle
{
    public string brand = "Ford";
    public void honk()
    {
        Console.WriteLine("Tuut, tuut!");
    }
}
class Car : Vehicle   // no `public`/`private` before Vehicle, unlike C++
{
    public string modelName = "Mustang";
}

Car myCar = new Car();
myCar.honk();                                        // inherited method
Console.WriteLine(myCar.brand + " " + myCar.modelName); // inherited field + own field

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.84
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C# Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).