내가 글로벌 함수를 작성하려고 해요 : 사용자 정의 문자열 클래스에 대한오버로드 << 내 수업
std::ostream& operator<<(std::ostream& out, const Str& str)
{
for(int i = 0; i < (int)str.mSize; ++i)
out << str.mBuffer[i];
return out;
}
. 잘 컴파일되지만 링크 할 때 :
1>Str.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class Str const &)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@@@Z) already defined in Main.obj
1>C:\Users\Ron\Documents\Visual Studio 2010\Projects\App\Debug\App.exe : fatal error LNK1169: one or more multiply defined symbols found
어떻게 여러 가지 정의가 존재합니까? 방금 Str 클래스를 만들었습니다.
헤더 파일에서 선언 한 것 같습니다. – GWW