pbuk
Science Advisor
Homework Helper
Gold Member
- 4,966
- 3,217
The third example would be ridiculous of course, I only wrote it to demonstrate that in c++ the amount of whitespace (i.e. spaces, tabs and new lines) separating symbols doesn't matter - pretty much anywhere we can put a space, we can start a new line, and anywhere we have a new line we can replace it with a space.
The important exceptions to this are compiler directives, which are not actually part of c++ itself, and these always start with
So to summarise, it doesn't matter how you lay out the template function declaration, it must always consist of exactly 3 parts separated by whitespace:
We can of course have as many template function definitions as we like: each one must start with the
The important exceptions to this are compiler directives, which are not actually part of c++ itself, and these always start with
#
as the first character of a new line, and in //
style comments which are terminated by the first following newline.So to summarise, it doesn't matter how you lay out the template function declaration, it must always consist of exactly 3 parts separated by whitespace:
C++:
template <class identifier> function_declaration;
// or
template <typename identifier> function_declaration;
We can of course have as many template function definitions as we like: each one must start with the
template
keyword, followed by a class or typename identifier, followed by a function declaration.
Last edited: