求解,初遇c++分文件错误,求解!

不分文件编译都能运行通过,等用到分文件编程就出问题了

launch.json


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,//修改此项,让其弹出终端
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\akyc\\c_path\\mingw32\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++"//修改此项
        }
    ]
}

tasks.json


{
    "tasks": [
        {
            "type": "shell",
            "label": "task g++",    //修改此项
            "command": "E:\\akyc\\c_path\\mingw32\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

main

img

报错

img

因为swap.h文件与main所在的文件不在同一个目录下

修改为#inlcude ".\\include\\swap.h"