我想将python嵌套的defs翻译成c ++,我正在使用嵌套的结构.
#include<iostream>
static void ffunc(int x, int y)
{
static int x1 = x;
static int y1 = y;
struct g
{
static void gfunc(int z)
{
static int z1 = z;
std::cout << x1 << y1 << z << std::endl;
struct h
{
static void hfunc(int k)
{
std::cout<< x1 << y1 << z1 << k << std::endl;
}
};
h::hfunc(4);
}
};
g::gfunc(3);
}
int main()
{
ffunc(1, 2);
}
Run Code Online (Sandbox Code Playgroud)
这段代码工作正常.问题是,我想要模板,以便嵌套函数可以使用任何类型参数.但是,当我尝试使用模板时:
#include<iostream>
template <typename t1>
static void …Run Code Online (Sandbox Code Playgroud)