|
发表于 2020-7-5 14:00:01
|
显示全部楼层
最后给你一个版本,如果不是你想要的,那我也懒得再说了
#include <iostream>
using namespace std;
template<int T1,int T2>
class One;
template<int i1,int i2, int T1, int T2>
void fun2(const One<T1,T2>&);
template<int T1,int T2>
class One
{
const static int NUM = 18;
template<int i1,int i2, int A1, int A2>
friend void fun2(const One<A1,A2>&);
};
template<int i1,int i2, int T1, int T2>
void fun2(const One<T1,T2>&)
{
cout
<< "One<" << T1 << ", " << T2 << ">::NUM=" << ( One<T1,T2>::NUM )
<< "\nviewing from\n\tfun2<" << i1 << ", " << i2 << ", " << T1 << ", " << T2 << ">\n"<< endl;
}
int main()
{
One<1, 1> one11;
One<2, 4> one24;
fun2<2, 3>(one11);
fun2<5, 6>(one11);
fun2<7, 8>(one11);
fun2<7, 8>(one24);
} |
|