#include <iostream> using namespace std; void f(int x, int a= 3, float b = 1.1); int main() { f(0); return 0; } ///:~ void f(int x, int a= 3, float b= 1.1) /* <span style="font-size:24px;color:#ff0000;">error C2572: 'f' : redefinition of default parameter : parameter 3 E:\vc++\MSDev98\Bin\45.cpp(4) : see declaration of 'f'</span> */ { cout <<a<<b; } /*
<span style="color:#ff0000;">//<span style="font-size:32px;">ok</span></span> #include <iostream> using namespace std; void f(int x, int = 3, float = 1.1); int main() { f(0); return 0; } ///:~ void f(int x, int a, float b) { cout <<a<<b; }
#include <iostream> using namespace std; void f(int x, int = 3, float = 1.1); int main() { f(0); <span style="white-space:pre"> </span>return 0; } ///:~ void f(int x, int a, float b) { cout <<a<<b; }<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">*/</span>
时间: 2024-10-29 10:45:42