0

actually in gcc compiler of linux everything is working fine without header files...
Then what is the real use of the header files in c & c++ langs ??


can anyone ans it??

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by gusano79
1

A header file is just like a cpp file. It's just code. Plain text. Nothing more, nothing less. It's used by the compiler to make the actual program. I'd be very impressed if you could write a C++ program without any text files.

Frequently, we write code that we like to repeat in more than one source file. For example, we might write some function declarations. If we put these declarations in one file, we can then use the preprocessor directive #include to copy that text into some other text, making our own lives easier.

That's essentially it. We chose to do it because it makes our lives easier. There is nothing stopping you writing every program in one huge text file. It's just a lot more effort than doing it sensibly and splitting your code into separate files.

Votes + Comments
.
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.