Error with multiple definitions of function

后端 未结 3 1775
感动是毒
感动是毒 2020-11-27 02:56

I am trying to relearn C++ after taking an intro course a few years ago and I’m having some basic problems. My current problem occurs when trying to use a friend function. H

3条回答
  •  难免孤独
    2020-11-27 03:16

    This problem happen because you are calling fun.cpp instead of fun.hpp. So c++ compile find func.cpp definition twice and throw this error. Pls, change line 3 of your main.cpp file, from #include "fun.cpp" to #include "fun.hpp"

提交回复
热议问题