2013-03-05 2 views
0
임 그것을 좋은 인터페이스를 만들고 사용에 문제가

... 내 설치 개요 (?) :C++ LNK 오류 2019 확인되지 않은 외부 기호 가상 오류 ...

에 "인터페이스"에 "빈"GraphicsLibrary.ccp와 GraphicsLibrary.H ...

virtual void drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize); 

!

당연히있다
void GraphicsLibrary::drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize) 
{ 
    //some code 
} 

는 "빈은"OpenGL.h 자신의 헤더 파일입니다 (이후 : 그 인터페이스, 그래서 "OpenGL을"는 그래픽 라이브러리이기 때문에 ... 그래서는 OpenGL.CPP이가와가 GraphicsLibrary.h)

는 그때의 OpenGL을 사용하고, 그 기재 그리기 기능을 사용하는 구체적인 기능 클래스를 가지고 (OpenGLVis_Enviroment.cpp)

OpenGL ogl; 
void drawObstacleUnderConstruction(Obstacle::Type type, const vector<Point>& points) 
{ 
for(//etcetc) 
     ogl.drawPoint(*it, 255, 255, 255, 3.0); 
} 

하지만 또한 근래

OpenGL openGL; 
openGL.drawText(something); 

하지만 지금은 (내가 다른 모든 기능과 같은이) 이러한 오류의 여지가 : 일부는 OpenGL 기능 ... 이 때문에 주요도있다을 사용 개 주요

1>OpenGLVis_Environment.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall GraphicsLibrary::drawPoint(struct Point const &,unsigned char,unsigned char,unsigned char,double)" ([email protected]@@[email protected]@[email protected]) referenced in function "void __cdecl DrawingFunctions::drawObstacleUnderConstruction(enum Obstacle::Type,class std::vector<struct Point,class std::allocator<struct Point> > const &)" ([email protected]@@[email protected]@@[email protected]@@[email protected]@@@[email protected]@@[email protected]@@Z) 

"GraphicsLibrary :: drawPoint ..."를 사용했기 때문에이게 있습니까?

+0

프로젝트를 어떻게 구축하고 있습니까? IDE 란 무엇입니까? –

+0

인터페이스를 사용하는 전통적인 방식은 pure 가상 멤버 함수 ('GraphicsLibrary :: drawPoint')를 가진 추상 기본 클래스 ('GraphicsLibrary')를 갖는 것입니다.이 클래스는 파생 클래스 ('OpenGL')를'OpenGL :: drawPoint'라고 부릅니다. –

+0

@AndyProwl 임 VS2012를 사용하여 그것을 컴파일 ... 나는 오히려 인터페이스를 만드는 전통적인 방법을 사용해야합니까? (Sander de Dycker가 말했듯이)? –

답변

1

링커에 대한 DrawingFunctions::drawObstacleUnderConstruction을 불평하고, 이는 void drawObstacleUnderConstruction 정의 ... 사전들에서 감사를 전 연령대에 온라인으로 검색하고 있지만, 인터페이스에 대한 예를 많이 ..를 찾기 어렵다 어떻게 그들과 함께 작업 자유로운 기능.

함수를 정의 할 때 이름을 한정하십시오.

void DrawingFunctions::drawObstacleUnderConstruction(Obstacle::Type type, const vector<Point>& points) 
{ 
    for(//etcetc) 
     ogl.drawPoint(*it, 255, 255, 255, 3.0); 
} 
+0

지금은 해봤지만 여전히 내 실수를 제거하지 못합니다. S –

관련 문제