c++ - error: Class has not been declared despite header inclusion, and the code compiling fine elsewhere -


so have class included in class keeps throwing compile error of form "error: 'problemclass' has not been declared. files set thusly:

#ifndef problemclass_h #define problemclass_h  #include <iostream> #include <cmath>  class problemclass {   public:      virtual void init() = 0; };  #endif 

and class error occurs looks this:

#ifndef aclass_h #define aclass_h  #include "problemclass.h"  class aclass : public base {   public:      void dosomething(problemclass* problem);  };  #endif 

the compile error occurs @ void dosomething();

i'm aware code here isn't enough solve problem. i've been unable create minimal example can reproduce it. question more general; sort of things might cause this? there in particular should for, or line of enquiry should following track down?

this code compiles fine in identical version of project.

help of sort appreciated, no matter how vague. i'm using codeblocks 10.05 mingw4.4.1 in win 7 64 bit.

you seem saying code showing doesn't produce compiler error having problem with. can guess. here possibilities:

  • you have forgot include problemclass.h file using problemclass.
  • you have misspelled name of problemclass either in own header file or in place using it. can hard spot if capitalization error such writing problemclass or problemclass instead of problemclass.
  • you have copy-pasted inclusion guard #defines 1 header file , forgot change defined names. first of 2 included header files take effect.
  • you have placed problemclass in namespace a, in case must refer problemclass a::problemclass if referring outside namespace a.
  • you may using templates , not expecting two-phase lookup work way it does.
  • you have misspelled file name in include. compiler not report error on if have old version of file under misspelled name.
  • you have made problemclass macro gets defined after include problemclass.h, in case see problemclass gets replaced else macro preprocessor.
  • you have defined problemclass in header file other problemclass.h , problemclass.h defines else.


  • Comments

    Popular posts from this blog

    c# - SharpSVN - How to get the previous revision? -

    c++ - Is it possible to compile a VST on linux? -

    url - Querystring manipulation of email Address in PHP -