c/c++可以有多个函数声明,但实现只能有一个
例子:
//file t_defs.h
#ifndef _T_DEFS_H_
#define _T_DEFS_H_
void say(void);
#endif
//file t_include.cpp
#include <iostream>
#include "t_defs.h"
using namespace std;
void say(void);
int main(void){
say();
}
void say(void){
cout << " hello" << endl;
}
//file t_include.cpp
#include <iostream>
#include "t_defs.h"
using namespace std;
void say(void);
/* error: multiple definition of `say()'
void say(void){
cout << " hello" << endl;
}
×/
#g++ t_include.cpp t_include_1.cpp
#./a.out
hello