C++ 模板友元
#include<iostream>#include<string>
using namespace std;
template<typename T>
class A
{ private:T name;
public:
A(T m):name(m){}
friendvoid show(A<T>&);
};
void show(A<string> arg)
{ cout<<arg.name<<endl;
}
void show(A<int> arg)
{ cout<<arg.name<<endl;
}
int main()
{A<string>a1("string1");
A<int> a2(5);
show(a1);
show(a2);
}
求问为什么这样通不过编译啊 应该是形参和实参不匹配吧{:9_229:}
页:
[1]