Headers?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Headers?

 
0
  #1
Feb 11th, 2007
I am using VC++...

I need to know how to add a header to the Application,
Can someone Joe, or anyone else Give me Step By step on how to do it...

Say I had a header called Bob.h

and I wanted to add it to my application Tauren

That needed it #include "b.h"

How would I add the Bob header to the application Tauren

If you dont understand what I said post...

Rember Step-By-Step I Am a noob you know!
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Headers?

 
0
  #2
Feb 11th, 2007
Copy the header file to the same directory that contains the project you intend to use it in. Then wherever it is needed, simply insert
  1. #include "whatever.h"
And it should work.

You can also use working directories (. and ..) to reference directories in your hard drive, although it's generally a bad idea to keep headers in some arbitrary folder on your hard disk if they are user-created.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Headers?

 
0
  #3
Feb 11th, 2007
Ok got it to work but now its asking me to find somewhere to excute it
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Headers?

 
0
  #4
Feb 11th, 2007
Originally Posted by Tauren View Post
Ok got it to work but now its asking me to find somewhere to excute it
Huh? Could you post the exact error messages please?
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Headers?

 
0
  #5
Feb 12th, 2007
Anthoer question....

If I wanna make a A header to say u would use it for the function

login to the game and then tell my server u did that would I have to make that header?
Actually how do u even make headerS?
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Headers?

 
0
  #6
Feb 12th, 2007
Originally Posted by Tauren View Post
Anthoer question....

If I wanna make a A header to say u would use it for the function

login to the game and then tell my server u did that would I have to make that header?
Actually how do u even make headerS?
Perhaps you should better learn what a header actually is.
http://www.cs.cf.ac.uk/Dave/C/node35.html

Basically you use it to declare functions and let the compiler know that they exist. That way you can call the functions in other files where the function isn't currently defined.

One trick with header files to avoid multiple inclusion errors is to encase the code inside preprocessor directives:
  1. #ifndef MYHEADERFILE_H
  2. #define MYHEADERFILE_H
  3.  
  4. // header file goes here...
  5.  
  6. #endif

Basically you can replace MYHEADERFILE_H with anything you want, as long as it's unique and isn't used anywhere else in the program.
Last edited by John A; Feb 12th, 2007 at 12:28 am.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Headers?

 
0
  #7
Feb 13th, 2007
u know how in games for the admin commands you have like / or .(command)
would i have to do like if .wave do animation.wave?
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Headers?

 
0
  #8
Feb 14th, 2007
So if you press .help in the c++ game it would say What do u need and when u do .kick it would tell you to type in a name when u type in .kick <name> it kicks the player and says player kicked
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 171
Reputation: Lazaro Claiborn is an unknown quantity at this point 
Solved Threads: 13
Lazaro Claiborn's Avatar
Lazaro Claiborn Lazaro Claiborn is offline Offline
Junior Poster

Re: Headers?

 
0
  #9
Feb 14th, 2007
I use Code::Blocks not VC++ but a header file (.h) contains prototypes, inline functions, macros, constants (i.e #define) and certainttypes of variables. When the IDE (i.e VC++) searches for include files it is usually in a default directory containing most, if not all, include files. If you have a corresponding (.cpp or .c++) file, it'd either be in the same directory or another - which varies among IDE configuration. Some IDE's and compilers allow you to transverse using a syntax such as (<../../header_file.h>). So a SUGGESTION would be to put your header files in the default directory and includ then via there. Also, to prevent inclusion, make sure you use the conditional preprossessor directives (i.e #ifndef HEADER_H etc...). If you decide to create and implement your own library(s) make sure it is under its own namespace. Last, you can always check out the HELP documentation for VC++ if all else fails; Microsoft usually has an exhaustive amount of documentation and even some tutorials for there products. Good luck my fellow Daniweb friend.

LamaBot
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Headers?

 
0
  #10
Feb 14th, 2007
ty
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC