C ++ lnk error 2019 unresolved external characters virtual errors due to interface ... (?)

I'm having problems creating a good interface and using it ... My review of settings:

"interface" GraphicsLibrary.H ...

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

with the empty GraphicsLibrary.ccp! because its interface, so "OpenGL" is a graphics library ... so I have OpenGL.CPP with:

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

which, of course, is "empty" by OpenGL.h (since its header file is GraphicsLibrary.h)

then I have a class with more specific functions that OpenGL uses and uses these basic drawing functions ... ( OpenGLVis_Enviroment.cpp ):

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

BUT I also have a main function using some OpenGL functions ... so main also:

 OpenGL openGL; openGL.drawText(something); 

but now I have many such errors (I have the same with all other functions):

 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)" ( ?drawPoint@GraphicsLibrary @@ UAEXABUPoint@ @ EEEN@Z ) referenced in function "void __cdecl DrawingFunctions::drawObstacleUnderConstruction(enum Obstacle::Type,class std::vector<struct Point,class std::allocator<struct Point> > const &)" ( ?drawObstacleUnderConstruction@DrawingFunctions @@ YAXW4Type@Obstacle @@ ABV?$vector@UPoint @@ V?$allocator@UPoint @@@ std@ @@ std@ @@Z) 

Is it because I use "GraphicsLibrary :: drawPoint ..."? I’ve been searching the Internet for ages, but it's hard to find many examples of interfaces .. and how to work with them ... Thanks in advance guys

0
source share
1 answer

The component complains about DrawingFunctions::drawObstacleUnderConstruction , and you have defined void drawObstacleUnderConstruction , which is a free feature.

Define a name when defining a function.

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

All Articles