-1

I get this error

myDate.cpp:(.text+0x160): undefined reference to `myTime::operator==(myTime const&) const'

It is my first time coding with header files and overloading operators so any help would be greatly appreciated. This is my code for myDate: http://pastebin.com/i4CLvWBS the Header: http://pastebin.com/ULircg5q

Where the errors are coming from theTime==date.getTime());

And here is an example of my overloaded operator

bool myDate::operator==(const myDate &date) const
{
  return (year == date.getYear() && 
          month==date.getMonth() && 
          day==date.getDay() && 
          theTime==date.getTime());
}

the time is from a different file called myTime and I have no clue how to properly define the operator and just in case you would new myTime to help me solve this problem : vWr5zwDq just follow that up in pastebin

I also made sure that myTime.cpp was linked properly because myTime.cpp is linked to myTime.h which is linked to myDate.h and myDate.h is linked to myTime.cpp and when I remover #include "myTime.h" from my myDate.h my code broke for that file.

#include "myTime.h"  #include "myTime.h"   #include "myDate.h"
myTime::myTime()     class myDate()        myDate::myDate()
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
torpedo178
  • 1
  • 1
  • 4

1 Answers1

0

You have to declare/define an appropriate bool operator==(myTime const&) const; for your class myTime as well.

If you did so, make sure that myTime.cpp is linked with the rest of the code properly.

See here for more in depth information about this error message and what linking actually means:
What is an undefined reference/unresolved external symbol error and how do I fix it?

Community
  • 1
  • 1
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190