1

I have two classes, Camera and Pixel. Camera has a vector of vector of Pixel (2D array) and Pixel uses static member functions from Camera.

In my Camera file I include my Pixel.hpp header before declaring the Camera class, so the compiler goes to the Pixel.hpp file, reads it and stops when it finds the call to the static member function saying:

src/../hdr/Pixel.hpp: In member function ‘void Pixel::ComputeVector()’:
src/../hdr/Pixel.hpp:32:26: error: ‘Camera’ has not been declared
 Vect2   screenSize = Camera::Instance().GetScreenSize();

I tried to do a forward declaration of Camera before the declaration of the Pixel class but it says:

src/../hdr/Pixel.hpp: In member function ‘void Pixel::ComputeVector()’:
src/../hdr/Pixel.hpp:33:26: error: incomplete type ‘Camera’ used in nested name specifier
 Vect2   screenSize = Camera::Instance().GetScreenSize();

And sometimes it considers forward declaration as errors...

I don't know what to do, I hope you'll help me with this problem, thank you for your attention

Xobtah
  • 464
  • 7
  • 20
  • you want to put all code into headers without .cpp files? – Evgeniy Oct 19 '16 at 15:05
  • This does not seem to be an exact duplicate of the referenced question because the dependency in one direction is caused by static member functions only. This case is particularly easy to refactor and might deserve its own answer. (Have voted to reopen) – Frank Puffer Oct 19 '16 at 15:10

0 Answers0