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
Post a Comment