使用模板传递指针,代码如下
template class X {
public:
void f() {
*T = 1;
}
};
namespace A {
volatile uint8_t* y = ((volatile uint8_t*) (0x3B));
volatile uint8_t z = 5;
}
int main(void) {
*A::y = 5;
X x;
x.f();
}
使用GCC编译器,错误信息:
error: 'A::y' is not a valid template argument because 'A::y' is a variable, not the address of a variabl。请问什么原因?