![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 345
Rep Power: 4
![]() |
creating header files
So i am making a c++ program with classes. I want to know how to use header files. I have some functions and some variables that are public. I know a head file has the class and the function declarations in it. I keep getting errors that the type is not right in the .h file. The class is called piece it has 4 public variables and 1 constructor. I say this:
class Piece; to define the class and then i need to define the constructor too right? But i can't figure out how to do that and do i have to delare the variables. I couldn't find a good example of one on the internet so could someone give me a good example of a c++ header file for a class so i can see how i am supposed to write the declarations in it? Thanks. |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4
![]() |
Re: creating header files
There are lots of tutorials on the net. See these google links (click here)
|
|
|
|
|
|
#3 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,120
Rep Power: 5
![]() |
Re: creating header files
Let's say your Piece class has one public constructor, and four methods to move it (left, right, up, and down). Your header file might look something like this:
C++ Syntax (Toggle Plain Text)
C++ Syntax (Toggle Plain Text)
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 345
Rep Power: 4
![]() |
Re: creating header files
thanks lectricpharaoh thats exactly what i was looking for
|
|
|
|
|
|
#5 |
|
Not a user?
Join Date: Sep 2007
Posts: 292
Rep Power: 2
![]() |
Re: creating header files
WOW what a bunch of gibberish
Nice try xmo; I don't know about anybody else, but I won't be following any of your links. No telling what could happen. Not to mention 2 things about your post: 1. you tromped all over somebody else's thread 2. this has nothing to do with programming |
|
|
|
|
|
#6 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4
![]() |
Re: creating header files
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating new files on the server | mleonid | PHP | 2 | Aug 15th, 2006 3:03 PM |
| question about header files and prototyping functions | linuxpimp20 | C | 13 | Sep 7th, 2005 9:28 AM |
| Header files | Klarre | C++ | 13 | Jun 15th, 2005 12:25 PM |
| Including header files | some1 | C++ | 8 | Apr 28th, 2005 9:59 AM |
| Including your home-made header files | Siphon | C++ | 3 | Feb 5th, 2005 9:26 PM |