Jump to content
  • Advertisement
Sign in to follow this  

c++ include issues

This topic is 4164 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im makeing jump to c++ (from c# and java) and so i started a program in C++ and im haveing some issues with include's any how i have 2 classes mainForm includes Register.h (a panel to be swapable with other panels on runtime) and Register includes mainForm.h but this causes errors at the line of this code snipit in class1 this->window =((System::Windows::Forms::Panel^) gcnew Register()); and gives this error error C2061: syntax error : identifier 'Register' what about includes am i not understanding? why cant 2 classes include each other? and how can i get around this problem btw i need Register panel to include mainForm for typecasting so i can relay information gatherd in the registerpanel back to the mainForm

Share this post

Link to post
Share on other sites
Looks like the problem is in how you've handled your header files. Unlike java c++ isn't very good at checking what has or has not been defined when its running through and compiling your code, so you have to watch out where you put your #includes.
Here's an example...


#include "second.h"

...(code that uses stuff from second.h)...


#include "first.h"


When the compiler goes through 'first.h', it will see the include for 'second.h' and jump there. But when it sees the include for 'first.h', it will jump back - without looking at anything! As a result, code in 'first.h' will come up with errors because the compiler doesn't know anything about 'second.h'.

Google should give you a few tutorials about the proper use of header files in c++. You might also want to read about how they are used with classes (more fun).

EDIT: Didn't have to look far [wink]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!