Reputation: 477
The following snippet works fine in both Visual Studio and g++.
template<typename T> class BST;
template<typename T>
class BSTNode
{
friend class BST<T>;
...
while this snippet works fine in VS, but not g++
template<typename K, typename V> class Map;
template<typename K, typename V>
class MapPair
{
friend class Map<typename K, typename V>;
...
What is wrong with this code? The errors I get are unhelpful, but here they are
error: wrong number of template arguments (1, should be 2)
error: provided for ‘template<class K, class V> struct Map’
error: friend declaration does not name a class or function
Any ideas?
Upvotes: 1
Views: 130
Reputation: 477444
Say friend class Map<K, V>;
. typename
may only be used to qualify dependent names, which K
and V
are not.
Upvotes: 1