VB programmer, struggling with Cpp

Started by
11 comments, last by Dreddnafious Maelstrom 21 years, 2 months ago
ok, that might explain it, ive got a copy of Vis C++ on my bosses computer, ill jump on here as soon as he leaves and test it out. ive been putting both my protoyes and implementations in the header files, i have a nasty feeling that that is a portion of my problem, anyway, thank you and ill let ya know when i get it sorted out.

edit ** ok, i just built a cpp file and a header file, declared my header file and all of the variables where available, weird.
Maybe it has something to do with the fact that the D3DDEVICE is an object as opposed to a first level type. i dont know guys, anyway thanks for your help.
"Let Us Now Try Liberty"-- Frederick Bastiat
Advertisement
//globals.hextern int g_CrudeAsHell;//globals.cpp#include "glboals.h"int g_CrudeAsHell;//any_other.cpp#include "globals.h"void do_stuff(){if(g_CrudeAsHell==0)   {   //stuff   g_CrudeAsHell=1;   }} 


You declare the variable to be ''extern''al in the header that all the cpp files include. In one (and exactly one) cpp file, you need to actually set aside space for the variable (I do this in the global.cpp file.) Then it''s the linker''s job to hook all the references to g_CrudeAsHell together.

You can precompile global.cpp into a static library, then link to that library instead of compiling global.cpp every time. Not a big deal for a couple of globals, but useful for something as large as, say, DirectX.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
@ Magmai Kai Holmlor and all, thanks for the help, will advise.
"Let Us Now Try Liberty"-- Frederick Bastiat

This topic is closed to new replies.

Advertisement