使用以下文件,我收到错误multiple definition of 'a'
,即使我只定义了一次?
header.cpp
add (int x, int y) {
return x+y;
}
header.h
#if !defined(header)
#define header
int add (int x, int y);
int a;
#endif
的main.cpp
#include <iostream>
#include "header.h"
#pragma once
using std::cout;
using std::endl;
int main() {
cout << "hi" << endl;
cout << a << endl;
}
完全复制代码