Skip to content

Commit d03acc3

Browse files
Rageking8TylerMSFT
andauthored
Improve C2548 (#4964)
* Improve C2548 * Update compiler-error-c2548.md * Update compiler-error-c2548.md fixed title casing * Update compiler-error-c2548.md typo --------- Co-authored-by: Tyler Whitney <[email protected]>
1 parent e250bb6 commit d03acc3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
---
22
description: "Learn more about: Compiler Error C2548"
3-
title: "Compiler Error C2548"
4-
ms.date: "11/04/2016"
3+
title: "Compiler error C2548"
4+
ms.date: "03/01/2024"
55
f1_keywords: ["C2548"]
66
helpviewer_keywords: ["C2548"]
7-
ms.assetid: 01e9c835-9bf3-4020-9295-5ee448c519f3
87
---
9-
# Compiler Error C2548
8+
# Compiler error C2548
109

1110
'class::member' : missing default parameter for parameter parameter
1211

13-
The default parameter list is missing a parameter. If you supply a default parameter anywhere in a parameter list, you must define default parameters for all subsequent parameters.
12+
The default parameter list is missing a parameter. If you supply a default parameter anywhere in a parameter list, you must define default parameters for all subsequent parameters in the current declaration or any previous declarations within the same scope.
1413

1514
## Example
1615

17-
The following sample generates C2548:
16+
The following sample generates C2548 for:
17+
18+
- `func1` because it's missing the default argument `b`.
19+
- `func3` because it's missing the default argument `c`.
20+
21+
The following sample doesn't generate C2548 for:
22+
23+
- `func2` because all the required default arguments are supplied.
24+
- The second `func4` declaration because the default argument `c` is supplied in the preceding declaration and is in the same scope.
25+
- The third `func4` declaration because both default arguments `b` and `c` are provided previously.
1826

1927
```cpp
2028
// C2548.cpp
2129
// compile with: /c
22-
void func( int = 1, int, int = 3); // C2548
30+
void func1(int a = 1, int b, int c = 3); // C2548
31+
32+
void func2(int a = 1, int b = 2, int c = 3); // OK
33+
34+
void func3(int a, int b = 2, int c); // C2548
2335

24-
// OK
25-
void func2( int, int, int = 3);
26-
void func3( int, int = 2, int = 3);
36+
void func4(int a, int b, int c = 3); // OK
37+
void func4(int a, int b = 2, int c); // OK
38+
void func4(int a = 1, int b, int c); // OK
2739
```

0 commit comments

Comments
 (0)