---
id: cpp-function-return
title: "C++ The Return Keyword"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["return values", "void vs typed return", "C++ return 키워드"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.83
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["cpp", "programming-language", "w3schools", "functions", "return"]
raw_sources: ["https://www.w3schools.com/cpp/cpp_function_return.asp"]
applied_in: []
github_commit: ""
---

# [[CPP The Return Keyword]]

## 🎯 한 줄 통찰 (One-line insight)
The "doubling game" example calls `doubleGame(i)` DIRECTLY inside a `cout <<` chain (`cout << "Double of " << i << " is " << doubleGame(i) << endl;`) without ever storing the return value in a variable first — proving a function call's return value can be used as an EXPRESSION anywhere a value is expected, not just assigned to a variable, letting five separate function calls (one per loop iteration) feed directly into output formatting. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`void` vs. a real return type** — `void` means no return value; a real type (`int`, etc.) plus `return` lets the function hand back a computed value. [S1]
- **Using a function call inline** — a function's return value can be used directly inside an expression (like a `cout <<` chain) without first storing it in a variable. [S1]
- **Storing the result in a variable** — equally valid, and often clearer for reuse. [S1]

## 📖 세부 내용 (Details)
- Returning a computed value: `int myFunction(int x) { return 5 + x; } cout << myFunction(3); // 8`. [S1]
- Storing the result before printing: `int z = myFunction(5, 3); cout << z;`. [S1]
- Using the return value directly inline inside a loop, with no intermediate variable: `int doubleGame(int x) { return x * 2; } for (int i = 1; i <= 5; i++) { cout << "Double of " << i << " is " << doubleGame(i) << endl; }`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).

## 🛠️ 적용 사례 (Applied in summary)
1부터 5까지 각 숫자를 두 배로 만들어 출력하는 "게임" 예제가 함수 반환값을 변수에 저장하지 않고 cout 문 안에서 바로 사용하는 실전 활용 사례로 제시됨. [S1]

## 💻 코드 패턴 (Code patterns)
Using a function's return value directly inline inside a loop's output, without an intermediate variable (C++):
```cpp
int doubleGame(int x) {
  return x * 2;
}
int main() {
  for (int i = 1; i <= 5; i++) {
    cout << "Double of " << i << " is " << doubleGame(i) << endl;
  }
  return 0;
}
```

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

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C++ Tutorial]]
- **관련 개념:** [[CPP Function Multiple]], [[CPP Function RealLife]], [[C Functions Parameters]]
- **참조 맥락:** return 키워드 — 함수 실전 예제(Function RealLife) 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — C++ The Return Keyword — https://www.w3schools.com/cpp/cpp_function_return.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ The Return Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).
