在C++中使用两级模板时出现问题

Problem with using two-level template in C++

本文关键字:两级 问题 C++      更新时间:2023-10-16

以下代码编译失败。为什么?

template<typename T, class C>
class ExPack_BASE_t
{
    Ex::u32 packageDestination = Ex::command_registration;
    Ex::u16 amoutOfParameters = (sizeof(C)/sizeof(T))-((sizeof(Ex::u32)+sizeof (Ex::u16)));
};

template<typename T>
class ExPack_registration_st : ExPack_BASE_t<T,ExPack_registration_st>
{
    T *firstName;
    T *secondName;
    T *fatherName;
    T *emil;
    T *birthDate;
    T *login;
    T *password;
    T *rePassword;
};

当我尝试编译它时,出现错误:

use of class template 'ExPack_registration_st' requires template arguments

使用ExPack_registration_stExPack_BASE_t<T,ExPack_registration_st>出现问题

您要传递的第二个模板参数是ExPack_registration_st,但这是模板的名称,而不是类型。尝试传递ExPack_registration_st作为第二个参数。- 比特维兹