Monday, November 7, 2011

Some Cryptic ERROR Messages of the Visual Studio 2008 C++ Compiler


Error    1    error LNK2019: unresolved external symbol "void __cdecl ReadData(class PathfinderGraph,class std::basic_string,class std::allocator >)" (?ReadData@@YAXVPathfinderGraph@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl Main(void)" (?Main@@YAHXZ)    pathfinder.obj    assn-6-pathfinder-pc

Cause: The function prototype is not the same as the function implementation.

Example:

/* function prototype */
void ReadData(PathfinderGraph & graph, string filename);

/* function implementation*/
void ReadData(PathfinderGraph graph, string filename)
{




notice the & in the function prototype.

No comments:

Post a Comment