类成员函数与类的头文件连接后总会报错说函数被重复定义
我类成员函数声明写在其他文件中,
#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; }
然后连接类的头文件在主程序中调用,总是会显示函数重复定义,可是我在头文件中的代码确实是写在

#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
宏定义里,为什么还是会出现函数被重复定义了。
