0

Hi everyone, I seem to be experiencing some problem with the linking of header files. I'm sort of creating Date structures and I have the following files:

  • Date.h: Class Date declaration
  • Date.cpp: Class Date functions definitions and auxiliary functions
  • DateFormat.h: Class DateFormat declaration (used to format Date objects)
  • DateFormat.cpp: Class DateFormat functions definitions and auxiliary functions
  • BadDate.h: Class BadDate declaration (used to throw exceptions)

Within my main programm I include Date.h, it is compiling well but the linker will give me this error: main_test.cpp||undefined reference to `Date::Date()'. It seems like it can't find the constructors definition within Date.cpp. When I combine the files into one big file above my main function everythin works great. :/

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mikrosfoititis
0

The issue is not with the header files, per se, but with the object files that the compiler produces before linking. You need to have the compiled object files linked together in the final version of the program, which (depending on how you are doing things) means having them together on the command line, or in a Makefile, or (most likely) in a project file of some sort. Just how you would proceed will depend on which compiler and/or IDE you're using.

Edited by Schol-R-LEA: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.