confusing thing abnout headers or wutrever

This is a discussion on confusing thing abnout headers or wutrever within the C++ Programming forums, part of the General Programming Boards category; ok you know those headers
#include <iostream>
well in the things you guys post the source to i barely ever ...

You need to put each header that contains the standard library code you want to access. You only need to put the headers that contain the code you want to access. So whenever you use something in your code, you need to make sure you know which header it is from and include that header.

So if you use cout, you need to include <iostream>. If you use string, you need to include <string>. If you use int, you don't need to include anything extra, since int is part of the language. If you use rand(), you need to include <cstdlib>. And so on. Your reference book or website should tell you which header is required (if any) for each thing you use.

thanks i can study them now but i have a question why do they make headers why dont they just put all the libs in the language
and if im making a big game and i cant keep track coudnt i just write all the headers

It is better to keep track of what you are using and what you aren't. It is best to understand what you are using and what you aren't. If you just include all the headers, your code will be sloppier and harder to follow, but it should still work.

The are several reasons that things are broken down into headers. One is that it separates interfaces from implementation (a good thing in program design). Another is that it speeds up compile times. If all the standard library code was automatically included, that would take the compiler a lot longer to find the things you are trying to use.

-different libraires were written by different people at different points in time

-logically organize similar routines into maintainable files

-It would greatly and pointlessly increase compile time to include every librairy

There would probably be little harm in you including all the headers you are familiar with in all of the source files you write. It might make your code misleading to someone else, and increase compile time. It shouldn't be that difficult to only include a header when you need it.