   Link error
  I have created a small library. Some objects can collide with each other, so I created a header file Min_Collision.h" to put all the collision functions inside.// overload collision() to work with all objects that can collide#ifndef MIN_COLLISION_H#define MIN_COLLISION_H// objects than can collide#include "Min_Rect.h"#include "Min_Sprite.h"#include "Min_AnimatedSprite.h"namespace Min{// Rectbool collision(const Rect &, const Rect &);// Spritebool collision(const Sprite &, const Sprite &);// Rect & Spritebool collision(const Rect &, const Sprite &);bool collision(const Sprite &, const Rect &);// TODO:// AnimatedSprite}#endif // MIN_COLLISION_HMin_Collision.cpp#include "Min_Collision.h"using namespace Min;// Rect & Rectbool collision(const Rect &rect1, const Rect &rect2){return Rect::Collision(rect1, rect2);}// Sprite & Spritebool collision(const Sprite &spr1, const Sprite &spr2){return Sprite::Collision(spr1, spr2);}// Rect & Spritebool collision(const Rect &rect, const Sprite &spr){return Sprite::Collision(spr, rect);}// Sprite & Rectbool collision(const Sprite &spr, const Rect &rect){ return Sprite::Collision(spr, rect);}I also collect all the headers of my library in Min_Graphics.h.#ifndef MIN_GRAPHICS_H#define MIN_GRAPHICS_H#include "Min_Surface.h" // Wrapper for SDL_Surface#include "Min_Image.h" // Immutable Image#include "Min_Sprite.h" // Static Sprite#include "Min_AnimatedSprite.h" // Animation#include "Min_Text.h" // Text#include "Min_Point.h" // 2D Point#include "Min_Rect.h" // 2D Rectangle#include "Min_Collision.h" // functions for collision#endif // MIN_GRAPHICS_HThen in main() I include "Min_Graphics.h" and use this line of code:// monster1 and monster2 are pointers to Sprite objectsif( collision(*monster1, *monster2) )monster2->SetAlpha(128);When I compile I get this:1>main.obj : error LNK2001: unresolved external symbol "bool __cdecl Min::collision(class Min::Sprite const &,class Min::Sprite const &)" (?collision@Min@@YA_NABVSprite@1@0@Z)1>C:\Users\User\Documents\Visual Studio 2008\Projects\Figure Fight\Release\Figure Fight.exe : fatal error LNK1120: 1 unresolved externalsWhy is this?   
  I guess the four overloads of collision inside the cpp file are in the global namespace, not in the Min namespace. Try putting "namespace Min { ... }" around them.Also, you know that C++ does not provide multiple dispatch, do you?void fun(Base *x);void fun(Derived *x);Base* x = new Derived();fun(x); // will call the Base* version, not the Derived* version;Quote:Original post by DevFredI guess the four overloads of collision inside the cpp file are in the global namespace, not in the Min namespace. Try putting "namespace Min { ... }" around them.That did it! Thanks :)Quote:Also, you know that C++ does not provide multiple dispatch, do you?void fun(Base *x);void fun(Derived *x);Base* x = new Derived();fun(x); // will call the Base* version, not the Derived* versionYeah I do. So if Sprite for example is derived, all parent classes will call the same collision function, which is what I want.   