C++/Hi sir


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

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


All Answers

Answers by Expert:

Ask Experts




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.


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.

©2017 About.com. All rights reserved.