문제가 있으며 해결 방법이 없습니다. 나는이 바보 간단하다 생각 :
Util.hpp중첩 클래스, 정의되지 않은 참조, 정적 메서드
class Util
{
public:
class BitParser
{
public:
static bool getBitAt(int buf, int idx);
};
};
Util.cpp
#include "Util.hpp"
bool Util::BitParser::getBitAt(int buf, int idx)
{
return true;
}
application.cpp 나오긴의
#include "Util.hpp"
int main(int argc, char* argv[])
{
Util::BitParser::getBitAt(1,1);
}
:
나는 3 개 파일이 위에 나열된 파일은 같은 디렉토리에 있습니다. 그리고 지금 링크 및 컴파일하려고하면 링커 오류가 발생합니다 :
$ g++ -o app application.cpp
application.cpp:(.text+0x19): undefined reference to `Util::BitParser::getBitAt(int, int)'
collect2: ld returned 1 exit status
무엇이 망가져 있습니까?
컴파일 명령에 util.cpp를 추가하십시오. –