Visual Studio: Internal Headers

Hey everyone,

I decided to try Visual Studio as I have a free license via university. I normally programm C++ in a unix environment using the gnu compiler. In a C++ course I take, the lecturer told us that it is good practice to use both an external and an internal header file for classes etc. Only put the class declaration into the external file and use an internal one to include your "Class.h" header + all other necessary headers and using instructions that functions may need.
Now, we put internal headers as .ih files. That seems to be somewhat uncommon, as I cannot recall seeing that on the interwebs before.
+ VS does not support such files. but i dont want to clutter up my header section with 2 headers for each class, seems unneccessary. The basic question behind all this bla bla is:
Is it simply redundat to use such internal headers, as it is common practice to put all functions of a class in one file? we used the one file per function approach before.

thanks!

ps: 2nd short question: does anyone have a good link or quick explanation why it is better to use pointers when looping through an array than using the indicies? google didnt come up with fitting examples
the lecturer told us that it is good practice to use both an external and an internal header file for classes etc.
News to me.

Now, we put internal headers as .ih files.
Never heard that before. I have to say that if I had someone at work doing that I'd tell them to stop messing around and stick with convention unless they had a really good reason not to. It's there for a reason. I can think of times when I would have class header files include other header files (#include <string> for example, and various other header files for other classes I might want to use in my class), but deliberately splitting a class' header files into other little header files doesn't seem helpful at all. It just means I'd have to go looking through a dozen files to see what's in the class, instead of just one.

we used the one file per function approach before.
That makes me flinch. This does not seem like a very helpful way to organise them. I suppose if each function was truly, truly, truly huge and you were constantly changing them, you might not want to have to recompile the whole lot every time, but even then it seems a bit silly and would imply that the problem was class design rather than lots of code.

does anyone have a good link or quick explanation why it is better to use pointers when looping through an array than using the indicies?
What's the difference?
This array[i] becomes *(array+i) by the time the compiler has finished with it (i.e. it will end up as a pointer anyway because that's how it works).
Last edited on
Topic archived. No new replies allowed.