0

I'm trying to refactor a DLL to control a OPOS device. After the device is claimed and enabled it starts a thread to constantly check for data received from the OPOS device. I declare the method in OposReader.h

But I figured it would be a better idea to pull out said method, and move it to a helper. So I created a class ReaderThreadHelper.h put it in... but in the thread I have to adjust values in OposReader.

So in the OposReader I call #include ReaderThreadHelper.h and in the ReaderThreadHelper.h I have to do a #include OposReader.h... and that starts the problem with the circular reference... and I'm too new to C++ to know how to fix it.

Should I even have done this to begin with? Is there a more proper way to do this?

Rost
  • 8,779
  • 28
  • 50
Robert Snyder
  • 2,399
  • 4
  • 33
  • 65
  • i'll accept your answer as soon as I can. You're right i put the include OposReader.h in my ThreadHelper.cpp and it worked :) me happy now. Thank you very much. – Robert Snyder Sep 12 '12 at 16:55

1 Answers1

1

Short answer: use forward declarations and include headers to .cpp files only.

Detailed explanation is here: Resolve circular dependencies in C++

Community
  • 1
  • 1
Rost
  • 8,779
  • 28
  • 50