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??

Recommended Answers

All 2 Replies

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.

commented: . +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.