October 2011
Beginner to intermediate
1200 pages
35h 33m
English
Template class declarations can have friends, too. You can classify friends of templates into three categories:
• Non-template friends
• Bound template friends, meaning the type of the friend is determined by the type of the class when a class is instantiated
• Unbound template friends, meaning that all specializations of the friend are friends to each specialization of the class
Let’s look at examples of each.
Let’s declare an ordinary function in a template class as a friend:
template <class T>class HasFriend{public: friend void counts(); // friend to all HasFriend instantiations ...};
This declaration makes the counts() function a friend to all possible ...
Read now
Unlock full access