用于在 vscode 中运行多个 cpp 类的代码运行器配置

Pay*_*m30 3 visual-studio-code vscode-code-runner

我有一个包含多个类和标头的 cpp 项目。我试图使用tasks和lunch.json来编译和运行它,但我放弃了。我意识到不久前我在使用 Python 解释器时遇到了问题,因此在使用 Python 时转到代码运行器配置来更改默认解释器。但是,当具有多个类和标头时,必须有一种方法使代码运行器即使在 cpp 中也能工作。这是我在配置中发现的:

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 $fileName  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},
Run Code Online (Sandbox Code Playgroud)

我看到只有一个文件被编译。我应该在上面的代码中添加什么以使 vscode 编译所有类?

Pay*_*m30 13

我将该行更改为

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 *.cpp  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},
Run Code Online (Sandbox Code Playgroud)

现在它就像一个魅力。