Sign in to follow this  
markrodgers11

accessing data from other .cpp files

Recommended Posts

markrodgers11    149
I am working on a text-based RPG and I defined a vector in my [i][b]game.cpp[/b][/i] file and now I am trying to access it from my [i][b]inputSystem.cpp[/b][/i] file, it shows that it is unknown? I am wondering how I can access this vector from this other .cpp files?

-Thanks

Share this post


Link to post
Share on other sites
Bregma    9200
Better yet, put the extern declaration in a header, and include that header in both .cpp files. That way, if either the declaration (in the header) or the definition (in game.cpp) gets changed bit the other does not, you get a compile failure instead of a mysterious runtime failure.

Also, putting shared variable declarations in header files documents them as being shared between .cpp files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this