Missing Function Body or Variable

Having just a function prototype will allow the compiler to continue without error, but the linker will not be able to resolve your call to an address because there is no function code or variable space reserved. You will not see this error until you create an actual call to the function that the linker must resolve.

TEST.CPP

void DoSomething(void);

void main(void)
{

DoSomething( );  // This line will cause LNK2001 because
                 // the prototype in testcls.h allows the
                 // compiler to think the function exists.
                 // The linker finds that it doesn't.
}

When using  C++, make sure that you include the implementation of a specific function for a class and not just a prototype in the class definition. If you are defining the class outside of the header file be sure to include the class name before the function in the Classname::memberfunction style.

class testcls {
 public:
  static void DoSomething(void);
};


void DoSomething(void)    // Should probably be testcls::DoSomething
{
}

void main(void)
{
testcls testclsObject;
testclsObject.DoSomething( );

}