-
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.
-
You didn't say what the error was.
You have several misspellings in your pen.h which are probably causing compiler errors.
-
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.
-
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.
-
Ok it worked it was in the misspelling Thank you. Im done using the compiler as a spellchecker maybe save myself some headaces.
-
Practice compiling after every single small change so it is easy to figure out what you changed that caused an error to appear.
-
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.