header files in C++

C, C++, Visual C++, C++.Net Topics

header files in C++

Postby SukhdeepMankoo » Wed Jun 02, 2010 9:39 am

I have seen header files in c++ are without *.h extension.while extension is preserved in c. why need to declare header files without any *.h extension? what will its benefit.

Thanks
User avatar
SukhdeepMankoo
Support Team
 
Posts: 64
Joined: Tue Oct 27, 2009 2:20 pm
Cash on hand: 2,291.80

Invitations sent: 0
Registered friends: 0

Re: header files in C++

Postby Neo » Wed Jun 02, 2010 11:35 am

Though .hpp is used in some of the modern C++ environments, .h is inherited and still used under C++. So practically you can use either .h or .hpp for header files under C++. But I don't think the extension of the header file matters at all as those are not getting compiled (Just added to the source file where #include directive appears).

However, you will have to use .CPP for C++ source files since C/C++ compilers mostly detect the compilation method based on the extension.
User avatar
Neo
Site Admin
 
Posts: 1145
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 66,229.10
Bank: 1,222,787.00
Location: London
Medals: 1
EC_Achievment (1)

Invitations sent: 85
Registered friends: 11
Highscores: 11

Re: header files in C++

Postby SukhdeepMankoo » Wed Jun 02, 2010 11:55 am

Thanks.
But i have also seen header file, where it does not have any extension.what abt that? why header files do not carry any extension.
User avatar
SukhdeepMankoo
Support Team
 
Posts: 64
Joined: Tue Oct 27, 2009 2:20 pm
Cash on hand: 2,291.80

Invitations sent: 0
Registered friends: 0

Re: header files in C++

Postby Neo » Wed Jun 02, 2010 12:30 pm

That's alright. As said before, when you put the #include directive, the header file will be placed on your source file, that's all. So it can have any extension or no extension at all.
User avatar
Neo
Site Admin
 
Posts: 1145
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 66,229.10
Bank: 1,222,787.00
Location: London
Medals: 1
EC_Achievment (1)

Invitations sent: 85
Registered friends: 11
Highscores: 11

Re: header files in C++

Postby SukhdeepMankoo » Fri Jun 04, 2010 6:50 am

Thanks Neo.
User avatar
SukhdeepMankoo
Support Team
 
Posts: 64
Joined: Tue Oct 27, 2009 2:20 pm
Cash on hand: 2,291.80

Invitations sent: 0
Registered friends: 0


Return to C/C++ Programming

Who is online

Users browsing this forum: No registered users and 1 guest