So I'm trying to do an example in C++ for Dummies about making a header file and I keep having problems compiling it. I'm using Dev C++ and I have three separate files one of them is a header
main.cpp:
1 2 3 4 5 6 7 8 9 10 11
|
#include <iostream>
#include <stdlib.h>
#include <string>
#include "safestuff.h"
int main (int argc, char *argv[])
{
cout << "Surprise, surprise!" <<endl;
cout << "The combination is (once again)" <<endl;
cout << SafeCracker(12) << endl;
return 0;
}
|
Which is giving me these errors:
safestuff.h `string' does not name a type
`cout' undeclared (first use this function)
`endl' undeclared (first use this function)
`SafeCracker' undeclared (first use this function)
The header file safestuff.h
string SafeCracker (int SafeID);
Won't even do anything.
And the file that contains the function safestuff.cpp
1 2 3 4
|
#include <string>
string SafeCracker(int SafeID) {
return "13-26-16";
}
|
Gives me another "`string' does not name a type."
I'm pretty new at this, and have a really basic understanding right now.
I'm doing exactly what the book says to do, but it just doesn't seem to work.