我正在尝试声明一个名为的基类,但在使用继承的类型和类内部时BASE
遇到了问题。我收到错误A
B
BASE
|In member function 'NODE& NODE::operator=(const NODE&)':|
16|warning: no return statement in function returning non-void|
In member function 'void BASE<T, SIZE>::init_A(int) [with T = NODE, unsigned int SIZE = 2u]':|
96|instantiated from here|
39|error: no match for 'operator=' in 'A<NODE, 2u>::DATA[index] = a'|
13|note: candidates are: NODE& NODE::operator=(const NODE&)|
#include <iostream>
class NODE
{
private:
public:
NODE(){}
~NODE(){}
};
template <class T, size_t SIZE>
class A;
template <class T, size_t SIZE>
class BASE
{
protected:
static T DATA[SIZE];
public:
BASE()
{
}
~BASE(){}
void init_A(int index)
{
A<T,SIZE>::DATA[index] = T();
}
};
template <class T, size_t SIZE>
class A : public BASE<T,SIZE>
{
protected:
public:
A(){}
~A(){}
};
template <class T, size_t SIZE>
T BASE<T,SIZE>::DATA[SIZE] = {};
int main()
{
BASE<NODE,2> base;
base.init_A(0);
return 0;
}