多文件编写时函数定义中的cout无法打印内容

  • 函数声明test.h文件
    #include
    using namespace std;
    void arr(int a,int b);
  • 函数定义test.cpp文件
    #include “test.h”
    void swap(int a,int b){
    int temp = a;
    a = b;
    b = temp;
    cout << "a= " << a << endl;
    cout << "b= " << b << endl;
    }

  • 函数调用Diaoyong.cpp文件
    #include
    #include “test.h”
    using namespace std;
    int main(){
    int a = 10,b = 20;
    swap(a,b);
    cout << "hello" << endl;
    system("pause");
    return 0;
    }

  • 以上代码运行后只打印diaoyong.cpp中的hello,而test.cpp中的cout内容缺没有打印

函数换个名称吧