Files
2nd/10_Wiki/Dev/Topic_CPP/CPP_Function_Default.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.5 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
cpp-function-default C++ Default Parameters Programming_Language draft conceptual
optional parameter
default argument value
C++ 기본 매개변수
B 0.86 2026-07-04 2026-07-04
cpp
programming-language
w3schools
functions
default-parameters
https://www.w3schools.com/cpp/cpp_function_default.asp

CPP Default Parameters

🎯 한 줄 통찰 (One-line insight)

This is a feature C never had — a function parameter can carry a FALLBACK VALUE (string country = "Norway") that's automatically used ONLY when the caller omits that argument entirely, meaning myFunction() and myFunction("USA") are BOTH valid calls to the SAME function with different effective parameter counts, something C's rigid argument-count matching never permitted. [S1]

🧠 핵심 개념 (Core concepts)

  • Default parameter value (param = value) — assigns a fallback value used when the caller omits that argument. [S1]
  • "Optional parameter" — the common name for a parameter with a default value. [S1]
  • Callable with or without the argument — the SAME function accepts calls with a different number of arguments, unlike C where argument count must always match parameter count exactly. [S1]

📖 세부 내용 (Details)

  • Default value used when the argument is omitted: void myFunction(string country = "Norway") { cout << country << "\n"; } myFunction("Sweden"); // Sweden myFunction("India"); // India myFunction(); // Norway (default) myFunction("USA"); // USA. [S1]

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

  • C에는 없던 기본 매개변수 기능: 인자를 생략하면 자동으로 기본값이 쓰이는 "선택적 매개변수(optional parameter)"는 C의 고정된 인자 개수 일치 규칙과 달리, 같은 함수를 다른 개수의 인자로 호출할 수 있게 해준다는 점이 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 국가 매개변수를 생략하면 "Norway"가 기본으로 쓰이는 예제가 선택적 매개변수의 실전 활용을 보여준다. [S1]

💻 코드 패턴 (Code patterns)

A default parameter value used when the argument is omitted (C++):

void myFunction(string country = "Norway") {
  cout << country << "\n";
}
int main() {
  myFunction("Sweden"); // Sweden
  myFunction();         // Norway (default used)
  return 0;
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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