如何为模板类静态变量指定初始化函数
需求:使下面的代码总共只输出3个Hello、a1/a2/a3的pw共用
const int N=1000007;
template<int base,int mod> struct hs{
static int pw[N];
hs(){
cout<<"Hello\n";
pw[0]=base;
for(int i=1;i<N;i++) pw[i]=1ll*pw[i-1]*i%mod;
}
};
template<int base,int mod> int hs<base,mod>::pw[N];
hs<141592,998244353> a1,a2,a3;
hs<142857,998244853> b1,b2,b3;
hs<141428,989244353> c1,c2,c3;