Program#1 is running fine, but program#2 gives linker error:
error LNK2005: "int GlobalVar" (?x@@3HA) already defined in file.obj
I know the header files are never compiled. Then in the above case, how the compiler knows the definition of variable var, but not able to find the definition of GlobalVar? What is the difference between this two programs?
In both the programe we have defined variables . In programe#1 we have difined static constant while in programe#2 we have defined GlobalVar .
i want to know why programe#1 is working fine where as programe#2 doesnot .