Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 调用模板化基类方法编译失败_C++_Templates - Fatal编程技术网

C++ 调用模板化基类方法编译失败

C++ 调用模板化基类方法编译失败,c++,templates,C++,Templates,我试图通过派生类调用模板化基类方法。 这是我的密码 struct base { template<typename t> void baseMethod(t s) { std::cout << s; } }; struct der : public base { }; int main() { der d; d.<int>(baseMethod(12)); } struct base { 模板

我试图通过派生类调用模板化基类方法。 这是我的密码

struct base
{
    template<typename t>
    void baseMethod(t s)
    {
        std::cout << s;
    }
};


struct der : public base
{
};


int main()
{
  der d;
  d.<int>(baseMethod(12));
}
struct base
{
模板
空基法(t-s)
{

尽管这个问题与继承无关,正确的语法应该是

d.baseMethod<int>(12);

将起作用。

尽管这个问题与继承无关,但正确的语法应该是

d.baseMethod<int>(12);

将起作用。

谢谢。语法将我的-标记为计时器后的答案。语法将我的-标记为计时器后的答案