![]() |
#2
rjsp2022-09-02 16:51
|

#include <iostream>
#include "Method.h"
using namespace std;
void showmenu(int a,int b){
int temp=a;
a=b;
b=temp;
cout<<"a=" << a << endl;
cout<<"b=" << b << endl;
}
#include "Method.h"
using namespace std;
void showmenu(int a,int b){
int temp=a;
a=b;
b=temp;
cout<<"a=" << a << endl;
cout<<"b=" << b << endl;
}
然后连接类的头文件在主程序中调用,总是会显示函数重复定义,可是我在头文件中的代码确实是写在

#ifndef METHOD_H_INCLUDED
#define METHOD_H_INCLUDED
#include "showmenu.cpp"
#include <iostream>;
using namespace std;
void showmenu(int a,int b):
#endif // METHOD_H_INCLUDED
宏定义里,为什么还是会出现函数被重复定义了。
