I am trying to call the static function AreaMap::staticInitialize(Model *) from a method in the class View. It compiles when I define the class AreaMap first but I get the error show below when I try declaring View first even though I forward declared AreaMap. Anyone know a way to keep the definition of View at the top?
#ifndef VIEW_H
#define VIEW_H
#include "Model.h"
class AreaMap;
class View {
public:
void linkMvc(Model * m) {
model = m;
AreaMap::staticInitialize(m);
}
Model * model;
};
class AreaMap {
public:
void static staticInitialize(Model * m) {
model = m;
}
Model * model;
};
#endif
Error:
inc/View.hpp: In member function ‘void View::linkMvc(Model*, Controller*)’:
inc/View.hpp:36:7: error: incomplete type ‘AreaMap’ used in nested name specifier
AreaMap::staticInitialize(m);