Jump to content
  • Advertisement

Archived

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

nexxus

Silly newbie question -> *.h and *.cpp

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

Hi... i have read some c++ books, but they only told the syntax and methods of the language. Right now, i want to build my own lib and have some problems to divide the code into headers and source files. For example: I have a function foo() which should be in the lib.cpp and some globals and defines and the foo-prototyp which sould be in the lib.h. The lib.cpp needs to have access to the stuff in the lib.h of course. Now i want to have a main.cpp which has access to the foo()-function AND the globals etc. in the lib.h. How to do? (or any from-the-ground-up tutorials for that ?) THANKS VERY MUCH

Share this post


Link to post
Share on other sites
Advertisement
Just include the lib.h (#include "lib.h") in your main.cpp. Don''t forget to add both files to your project if you are using VC++.
(BTW if you want to make a "real" library you need to compile the lib.cpp to a .lib-file and then include the lib.h in your main.cpp and add the .lib-File to your project instead of the lib.cpp)

baumep

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!