Skip to main content
gamedev.net
🔒 Locked

Spreading code over multiple cpp files

Started by Drath 1 reply 250+ views
Original Post
Drath
Drath
I am a begginer to c++ though not to programming in general. One problem I have run in to is how to access a something from one source code to another. In functions, I set the object as a parameter then access it with relative ease but if I have my own object: typedef struct tagCam { float xpos, ypos, zpos; float yrot, lookupdown; } CAM; I have had to place it in both files for CAM to be detected. How can I do it so that I need only to place it in one? Is it through header files? If so I will need a little explaining... Thanks...
Zorak
Zorak
put the struct in a header file (cam.h) and in the source file you use #include in the top.

#include "cam.h"

Domine non secundum peccata nostra facias nobis
Drath
Drath
Thanks a lot!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.