问题描述
test2.h
#ifndef TEST2_H_INCLUDED
#define TEST2_H_INCLUDED
#include "test1.h"
inline int add(int,int);
#endif // TEST2_H_INCLUDED
test2.cpp
#include "test2.h"
inline int add(int a,int b){
return a+b;
}
main.cpp
#include <iostream>
#include "test2.h"
int main()
{
std::cout << add(1,2);
return 0;
}
错误:
但是,如果我从文件中删除inline
,代码将编译并执行良好。我在做什么错了?
注意:我已经看到了堆栈上的所有线程溢出,尽管它们与我的问题相似,但是答案无法解决我的问题
使用mingw编译器和代码块