There are three common declaration structures related to function templates: declaring function templates, declaring specializations, and declaring instances.
I think you are not specializing here, you just want to declare the template. Because you used template parameters in the function parameter list. Refer to the first way of writing.
If you don’t do too much template development, the overloading of stream’s << is actually this routine, just memorize it. Another common form is
I don’t think it’s necessary to change the compiler. I can learn the syntax from the book. If you want to search, you have to search for "ostream overloading writing method" and then compare the codes. If it is a very deep template usage, the copy syntax error message search will not be able to find out the reason.
The error message the compiler gives you is very clear. Maybe you can’t read English. Don’t worry about which compiler to choose, the compiler is innocent, gcc is pretty good
n is not declared in scope
There are three common declaration structures related to function templates: declaring function templates, declaring specializations, and declaring instances.
The same thing happens if you replace it with operator overloading
I think you are not specializing here, you just want to declare the template. Because you used template parameters in the function parameter list. Refer to the first way of writing.
If you don’t do too much template development, the overloading of stream’s << is actually this routine, just memorize it. Another common form is
I don’t think it’s necessary to change the compiler. I can learn the syntax from the book. If you want to search, you have to search for "ostream overloading writing method" and then compare the codes. If it is a very deep template usage, the copy syntax error message search will not be able to find out the reason.
The error message the compiler gives you is very clear. Maybe you can’t read English. Don’t worry about which compiler to choose, the compiler is innocent, gcc is pretty good