No “redefinition of default parameter error” for class template member function?

8.3.6 §6 The default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition Example: class C { void f(int I = 3); void g(int i, int j = 99); }; void C::f(int I = 3) // error: default argument already { } // specified in class scope void C::g(int I = 88, int j) // in this translation unit, { } // C::g can be called with no argument end example According to the standard, it should give you an error.

8.3.6 §6 The default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition. Example: class C { void f(int I = 3); void g(int i, int j = 99); }; void C::f(int I = 3) // error: default argument already { } // specified in class scope void C::g(int I = 88, int j) // in this translation unit, { } // C::g can be called with no argument --end example According to the standard, it should give you an error.

3 @tusbar you are quoting only part of that paragraph. It says at the start of it "Except for member functions of class templates, ...". – Johannes Schaub - litb Mar 19 '10 at 19:10 4 Interesting: C++03 differs from C++98.

What @tusbar quoted is the C++98 text, while C++03 added the exception for class templates and added to the paragraph "Default arguments for a member function of a class template shall be specified on the initial declaration of the member function within the class template. " - I suspect that this is meant to forbid default arguments in out-of-class definitions in case of members of class templates by saying that any default arguments shall be specified in-class instead of outside of the class however to me it seems unclear (does it forbid duplicates? ).

– Johannes Schaub - litb Mar 19 '10 at 19:23 1 I looked into open-std. Org/jtc1/sc22/wg21/docs/cwg_defects. Html#217 and it seems like the intention is to forbid any out-of-class default arugments for template members.

Also, I think now since the out-of-class default argument is regarded distinct from the one in-class, even if lexically identical, it violates the "shall be specified on the initial declaration" constraint. So this makes sense if you get a compile time error. The "issue 3.13" John Spicer refers to can be read in this document: open-std.Org/jtc1/sc22/wg21/docs/papers/1995/N0607.

Pdf – Johannes Schaub - litb Mar 19 '10 at 20:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send