C++/Hi sir

Advertisement


Question
Why don't we need .h extension header file in c++?


Answer
Hi ram, thank you for the question.

In C++, the spec dictates that header files have no extension. Personally, I find that to be a bad idea, but I suppose they thought otherwise. The .h extension is for headers in the C language. Some people actually use another extension for C++ that is .hpp (header plus plus). While this is not commonly used, I have seen it used before.

The extensionless header files are very common in the built in C++ classes. Think of files like <string>, <iostream>, <iomanip>, and <ctime>. All of those are C++ header files that have no extension at all. If you right click on the include directive for each header file, you can observe their contents, if you are curious.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.