I’ve never been clear on exactly how much of the declaration line (typically placed in the header file) makes it into the first line of the function definition. Some keywords cause compilation to fail if they’re repeated in the definition, some don’t.
As an example, consider an exception class inherited from std::exception. The redefinition of the what() function typically looks like
virtual const char* what() const throw();
Okay, fine. If I define this in a source file, and I copy over this line exactly
virtual const char* what() const throw() {}
compilation fails with a message like “virtual outside class declaration”. I delete “virtual” and it compiles fine. What are the rules for what parts of the function declaration need to be repeated in in its definition? Static? Inline? Is there a reference that describes concisely which parts are necessary?
Here is a very good explanation of what goes into declaration and what goes into definition: