Adding the using statement for replacing int32 in cpp as well .h?

Hi there,
just wondered why you(Ben) used the using statement for int32 in the cpp file that already #include “FBullCowGame.h” ? is it best practise ?

I already had switched the code to int32 and just changed it straight away in FBullCowGame.cpp because i thought we were including the header file so it didn’t need to be set again, it works either way just wondered whether it was a best programming practise.

Thanks :slight_smile:

Kind Regards
Steve

4 Likes

Well I did the same thing as u did and it didn’t worked for me… So I just has to use the ‘using’ statements on all three files :frowning:

I noticed this too. It works fine for me to just have “using int32 = int;” in the FBullCowGame.h file, since it (the header file) is included in the other two files (main.cpp and FBullCowGame.cpp). I would also like to know if it is best practice to put it in the top of the other two files as well or if that is redundant.

I did the same thing with only including it in the header file. Game worked fine, though I am wondering if it might cause problems later on?

I also placed the “using int32 = int” in just the .h and main file. Not in the .cpp. It works perfectly fine for me.

I personally don’t think it will cause problems later on, because, as Ben said in an earlier video, a #include is like pasting a block of code at the top of your file.

Technically my program even works if I place it ONLY in the FBullCowGame.h file, but I wouldn’t do that, for the sake of readability.

Well @VeganBurrito86 in order to use and instantiate the Class BullCowGame you have to #include the header file in the main.cpp. If this header file it isn’t included you wont be able to use your class.

But, using the using int32 in the header file and in the main.cpp is good for readability like @celiue posted. And to not make main.cpp dependent of the header file, that is important.

Privacy & Terms