mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Minor fix
This commit is contained in:
parent
c21cf5a1e2
commit
05c2617aaf
@ -489,15 +489,16 @@ void barkThreeTimes(const T& input)
|
|||||||
|
|
||||||
Dog fluffy;
|
Dog fluffy;
|
||||||
fluffy.setName("Fluffy")
|
fluffy.setName("Fluffy")
|
||||||
barkThreeTimes(fluffy); Prints "Fluffy barks" three times.
|
barkThreeTimes(fluffy); // Prints "Fluffy barks" three times.
|
||||||
|
|
||||||
// Template parameters don't have to be classes, though this is used very rarely:
|
// Template parameters don't have to be classes:
|
||||||
template<int Y>
|
template<int Y>
|
||||||
void printMessage() {
|
void printMessage() {
|
||||||
cout << "Learn C++ in " << Y << " minutes!" << endl;
|
cout << "Learn C++ in " << Y << " minutes!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And you can explicitly specialize templates for more efficient code:
|
// And you can explicitly specialize templates for more efficient code (most
|
||||||
|
// real-world uses of specialization are not as trivial as this):
|
||||||
template<>
|
template<>
|
||||||
void printMessage<10>() {
|
void printMessage<10>() {
|
||||||
cout << "Learn C++ faster in only 10 minutes!" << endl;
|
cout << "Learn C++ faster in only 10 minutes!" << endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user