lundi 16 mars 2015

C++ Cannot find Include


In main.cpp I keep getting errors saying that print was not defined (and other errors of the sort.


I have print() defined under a header file called "misc"


misc.h



#include <iostream>
#include <cstdlib>
#include <fstream>
#define MISC_H
#ifndef MISC_H

void print(string str) { cout << str << endl; }

string userIn(string prompt = "Option:") { //For collecting user responses
string response;
print(prompt);
cin.clear();
cin.sync();
getline(cin, response);
if (!cin) { response = "wtf"; }
else if (response == "512") { //Secret termination code
print("Program terminated");
exit(0);
}
print("");
return response;
}
#endif


Then in main.cpp I #include Headers/misc.h" (The header file is located in a separate folder)


Is there something I'm doing wrong here?




Aucun commentaire:

Enregistrer un commentaire