visual c++ undeclared identifier -


in a.h

#pragma once include "b.h" class {     b* aptrtob; } 

in b.h

#pragma once include "a.h" class b{     a* aptrtoa; } 

visual c++ says "error c2065: 'a' : undeclared identifier"

any ideas?

thanks!

you have cyclic inclusion. #pragma once preventing infinite inclusion result this, means either a won't have definition of b above or b won't have definition of a above it, depending on ever compiled first.

the solution not #include header files, since need forward declaration declare pointer:

#pragma once  class b;  class {     b* aptrtob; }; 

and:

#pragma once  class a;  class b {     a* aptrtoa; }; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -