请问一下c++无法连接到自己写的可变参数函数

vscode头文件路径已经包含了,源文件也加入编译了。原来自己写的固定参数的函数可以正常链接。

最近学习可变参数,这样写好头文件和源文件以后显示找不到可变函数

请问是设置有问题吗?

问题相关代码

printX(1,"hello");
#include<iostream>
using namespace std;


void printX();

template <typename T,typename... Types>
void printX(const T& firstArg,const Types&... args);


#include "myTest.h"

void printX()
{

}


template <typename T,typename... Types>
void printX(const T& firstArg,const Types&... args)
{
    cout<<firstArg<<endl;
    printX(args...);
}

运行结果及报错内容

undefined reference to `void printX<int, char [6]>(int const&, char const (&) [6])'
collect2: error: ld returned 1 exit status
The terminal process "bash '-c', 'g++ -g */test_c++.cpp -I */Includes/ /Src/.cpp -o */Output/test_c++.out -pthread'" terminated with exit code: 1.

我的解答思路和尝试过的方法

把代码都放到主文件,不放在单独的文件就可以正常调用

我想要达到的结果

怎么样才能放在单独的文件,可以正常调用?

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。