i have a Header file that i will be using for multiple programs. this file specifies integers (its for my calculator programs).

is it possible to have an integer value represented as AB if the two other integers are represented as A & B without getting a compiling error?


short int a;
short int b;
short int ab;

-- i want to know if this is possible

please let me know be cause i have no space left since i am at

short int z;


7 Years
Discussion Span
Last Post by firstPerson

>>- i want to know if this is possible

Why not? You could also declare them as int a, b, ab; . If you put that in a header file then you have to use the extern keyword in the header file, e.g. extern int a, b, ab; then do the same thing in one, and only one, *.c or *.cpp file but without the extern keyword. extern tells the compiler that the integers will be actually declared somewhere else. If you don't use extern in the header file the compiler will puke up errors that the integers have been multiply declared ... in each *.cpp file which includes the header file.

Edited by Ancient Dragon: n/a


for that matter I'm pretty sure that the following is valid code:

int theMostAwesomestIntEver;

Seems like at your level, you don't need to worry about header files, because it will
only complicate things for you. Just stick with 1 file for now, the main file.
And by the way all of this is valid :

int a;
int aa;
int aaa;
int b;
int c;
int abc;
int ac;
int ab;

You see, what matters is that NO TWO VARIABLE NAMES ARE THE SAME, if you follow that
then you will be fine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.