【发布时间】:2013-04-19 08:20:44
【问题描述】:
我的代码具有以下基本结构:
namespace A{
template<class T,unsigned DIM>
class CMyTable{
...
public:
template<class T,unsigned DIM>
friend std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
}
};
}
最初的问题是让我的操作员
我试过这个解决方案:How do I define friends in global namespace within another C++ namespace?
namespace A{
template<class T,unsigned DIM>
class CMyTable;
}
template<class T,unsigned DIM>
std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
namespace A{
template<class T,unsigned DIM>
class CMyTable{
...
public:
template<class T,unsigned DIM>
friend std::ostream& ::operator<<(std::ostream& s, const CMyTable<T,DIM>& vec);
}
};
}
template<class T,unsigned DIM>
std::ostream& operator<<(std::ostream& s, const CMyTable<T,DIM>& vec){
// [...]
}
我收到此错误:错误 C2063: 'operator
public:
template<class T,unsigned DIM>
friend std::ostream& ::operator<<(std::ostream& s, const CMyTable<T,DIM>&
有人有什么想法吗?
谢谢。
【问题讨论】:
标签: c++ templates namespaces operators friend