Promblem with the .h

This is a discussion on Promblem with the .h within the C++ Programming forums, part of the General Programming Boards category; I new to c++ and dont know alot so plz bare with me. Im trying to do this code out ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Promblem with the .h

    I new to c++ and dont know alot so plz bare with me.
    Im trying to do this code out of C++ for Dummies and i though i done everthing right. (cant be to hard just copy the text right?)
    Well I am getting a error of "In file include from main.cpp" on line 4 of main.cpp
    this is the main.cpp
    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <string>
    #include "pen.h"
    using namespace std;
    int main( int argc, char *argv[])
    {
    This is the pen.h
    Code:
    #include <string>
    using namespace std;
    enum color {blue, red, black, clear};
    enum penstyle {ballpoint, felt_tip, fountain_pen};
    class pen {
    public:
           color inkcolor;
           color shellcolor;
           color capcolor;
           penstyle style;
           float lenght;
           string brand;
           int inklevelpercent;
           void writeonpaper(sting words){
                if (inklevvelpercent <=0 ) {
                                     cout << " ........ out of ink!" << endl;
                                     }
                else {
                     cout << words << endl;
                     inklevelpercent = inklevelpercent - words.length();
                     }
                     }
           void breakinhalf() {
                inklevelpercent = inklevelpercent / 2;
                length = length / 2.0;
                }
           void runoutofing() {
                inkleelpercent = 0;
                }
    };
    Is it giveing me a error on line 4 in the main. I can only assume it has some thing to do with the pen.h. Thank you for any help or input you give. If you need more information just say.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    You didn't say what the error was.

    You have several misspellings in your pen.h which are probably causing compiler errors.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    3
    I cleaned up the spelling (maybe i should slow down a little) i belive i got all of them, but the error is still there. im going to go back and check it again.
    the error is: in file include from main.cpp
    it is on line 4 of the main.cpp that is the line of #include "pen.h"
    Im useing Dev-C++ 4.9.9.2.
    sorry about that.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    Copy and paste the entire error. There should be more to it than what you posted.

    I count at least 4 misspellings that would cause a compile error like the one you mentioned and a 5th that might cause a different error in your main.cpp. There might be more.

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    3
    Ok it worked it was in the misspelling Thank you. Im done using the compiler as a spellchecker maybe save myself some headaces.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    Practice compiling after every single small change so it is easy to figure out what you changed that caused an error to appear.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    Perhaps it can't find the header file, since there seems to be only one (undisclosed) error.

    By the way, 'using namespace' in header files is bad form - search the board to find out why.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. .h files: "constant already defined"
    By wakeup in forum C++ Programming
    Replies: 11
    Last Post: 11-22-2005, 04:31 AM
  2. .h file help
    By Rune Hunter in forum C++ Programming
    Replies: 3
    Last Post: 02-06-2005, 01:49 PM
  3. Difference between .h and .c files
    By Metalix in forum C Programming
    Replies: 9
    Last Post: 01-19-2005, 07:38 PM
  4. placement of (.h) and (.cpp) files..!?
    By matheo917 in forum C++ Programming
    Replies: 3
    Last Post: 02-22-2003, 05:37 PM
  5. including an .h file
    By Smiley0101 in forum C++ Programming
    Replies: 3
    Last Post: 02-08-2003, 11:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21