c++builder - global variable from Project1.cpp accesible in Unit1.cpp -


how declare global variable in project1.cpp , read in unit1.cpp ? question c++ builder

use extern keyword in unit1.cpp refer declaration project1.cpp.

for example, if in project1.cpp have

// global variable  int myglobalvar; 

then in unit1.cpp should have

extern int myglobalvar; 

however, practice questionable , should avoided. important programming principles modularization , decoupling can denied usage of global variables.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -