|
发表于 2020-6-22 20:00:02
|
显示全部楼层
#include <iostream>
template<class T>
class Bar
{
public:
Bar(T b) : b_(b) {}
template<class T2>
friend void Foo1(const T2&);
private:
T b_;
};
template <class T2>
void Foo1(const T2& t)
{
std::cout << t.b_ << std::endl;
}
int main()
{
Bar<int> b(5);
Foo1(b);
return 0;
} |
|