Can't create Operator <<

Hello, I trying to creator an operator << between an ostream and a SENTENCE_TYPE (an Enum):

//Sentence type
enum class SENTENCE_TYPE {ANSWER, MESSAGE, NONE};

//operator
// define needed operator to conversion
std::ostream& operator<< (std::ostream& os, SENTENCE_TYPE type) {
	if (type == SENTENCE_TYPE::ANSWER)
		os << 'A';
	else if (type == SENTENCE_TYPE::MESSAGE)
		os << 'M';
	else
		os << 'N';
	return os;
}

but when I compile it, I have this error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2005	"class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,enum SENTENCE_TYPE)" (??6@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV01@W4SENTENCE_TYPE@@@Z) already defined in DoNotAnswerGameModeBase.cpp.obj	DoNotAnswer	G:\WORK\EXODIA STUDIO\EXODIA STUDIO\Exodia Video Game\DoNotAnswer\App\DoNotAnswer\Intermediate\ProjectFiles\MSC_SaveSystem.cpp.obj	1	

I don’t know how to fix this. thanks in advance.

the code you shared is from .h or cpp file ? ( i suppose .h / DoNotAnswerGameModeBase )

check you have the #pragma once
in you .h file
does MSC_SaveSystem is a file from your project ? if yes does it include the said file ?
could it be because you made an implementation and copy past it and forgot to remove the old one ?

the code is in the SC_StoryLines.h and there is #pragma once. and the redefine error is in the DoNotAnswerGameModeBase.h.obj.
SC_StoryLine.h is included in the file MC_StoryClass.h which is included in the MSC_SaveSystem (the file which uses this operator) which is included in the DoNotAnswerGameModeBase.h.

I just tried, and if you move it to the cpp file it’s intended to be use, it does compile without error

it works, thanks