Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sir Sapo

C++ classes

This topic is 5121 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

If I made a class in C++ , and have an instance of it in my main program , do they have to be in the same directory when I compile them? If so afterwards , will the class be included in the executable? If I am not making sense(im still thinking in Java) , then let me know and I will try and rephrase the question.

Share this post


Link to post
Share on other sites
Advertisement
You''re not even thinking in Java. In Java, the path to your .java file is determined by its package hierarchy. In C++, there are no such restrictions. You can place your source and header files wherever you like, and you can use relative paths in your #include directives. The key is not in your file locations, but in proper forward declarations of all entities.

Read this article for more details.

Share this post


Link to post
Share on other sites
Of course they don''t have to be in the same dir. You just have to specify the path in include directive(e.g. #include "subdir\myclass.h") or add the directory where the class is to the list of default include files locations(in project properities or dev properities) and then #include <myclass.h>. I assume you have added lib or cpp file with methods'' definitions to your project...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!