Current location: Hot Scripts Forums » Programming Languages » C/C++ » how to create a header file in Visual C++?


how to create a header file in Visual C++?

Reply
  #1 (permalink)  
Old 03-02-05, 05:41 AM
dummies_05 dummies_05 is offline
New Member
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
how to create a header file in Visual C++?

i am a beginner, met another problem during my learning, hope someone can help me.

1) how to create a header file (.hpp) in Visual C++?

2) after create the header file, i include it in my c++ program(.cpp) something like this "#include <abc.hpp>".

so what i have to do is build my .cpp program and then execute it like usual? or do i need to take extra steps?

appeaciate lot if some expert can help me with this. thanks.
Reply With Quote
  #2 (permalink)  
Old 03-03-05, 04:14 AM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
hi dummies_05,
i assume you use ms visual studio (.net). just follow this step.
1. after opening your project, go to this section: Files > New
select the files tab and choose the section C/C++ header
2. after creating your header file, place it at the same folder with your project file and then include it using syntax: #include "abc.hpp"

if you want to use c++ stl in your c++ file, you should not specify native header extension in your include code.
for example
Code:
#include <iostream>
#include <string>
#include "abc.hpp"

using namespace std;

//Rest of your code
regards,
__________________
just an ignorant noob with moronic solution...

Last edited by moronovich; 03-03-05 at 04:20 AM.
Reply With Quote
  #3 (permalink)  
Old 03-15-05, 03:15 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
if you want to use c++ stl in your c++ file, you should not specify native header extension in your include code.
you mean you don't suggest using .h extension for user-defnied header files? if this is what you meant, why is that? or you meant we shouldn't use <> but "" for user-defined header files!? if the latter is what you meant, I understand

and as for creating a new header file simply after you open your workspace/project, right click on "Header Files" and then "Add -> Add new item"..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #4 (permalink)  
Old 03-15-05, 08:20 AM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
i meant, one shouldn't use the ".h" extension for native headers (for eg: iostream, string, etc). this is because when you don't specify it, compiler will assume you're working with the standard template library (stl) and bind your code into default namespace. further reading, C++ programming language by Bjarne Stroustrup.

regards,
__________________
just an ignorant noob with moronic solution...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Create a file code ancdy Script Requests 2 01-24-05 11:02 AM
create a link to an exe file Sash HTML/XHTML/XML 4 09-07-04 07:51 PM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 03:09 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


All times are GMT -5. The time now is 04:34 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.