I started getting the error "error C2059: syntax error:" default argument "for a line of code declaring a function with a string argument that was given a default parameter. This was clearly a little disappointing since the error message was not exactly enlightening (I I know that this is the "default argument"!), And the exact ad will work elsewhere.
After the ad changed a bit, I found that its position in its containing class really has an effect. Narrowing it down, I found that I am declaring a slightly different function by including a semicolon after one of the default parameters. The compiler seemed perfectly beautiful, which seemed a little strange. I researched a bit more and came up with the following test case to try to figure out what was going on:
enum TestEnum1
{
TEST_ONE
};
class TestClass
{
public:
enum TestEnum2
{
TEST_TWO,
TEST_THREE,
TEST_FOUR
};
void Func1( int iParm = TEST_ONE; );
void Func2( std::string strParm = "" );
};
As can be seen from the above code, Func2 throws the compilation error mentioned above. If I translate Func2 over Func1 then everything compiles fine.
If I switch the default parameter in Func1 to an explicit number or use the enumeration declared in TestClass, then I get the expected syntax error for this line.
, , , , , -, , , , , .
- ? ? , . - , , .