/*--------------------utilities.h-------------------------------------*/
#ifndef UTILITIES_H
#define UTILITIES_H
template<class T> int compare(const T&,const T&);
#include<utilities.cpp>
#endif
/*--------------------utilities.cpp-------------------------------------*/
template<class T> int compare(const T &v1 , const T &v2)
{
if (v1 < v2) return -1;
if (v2 < v1) return 1;
return 0;
}
/*--------------------main.cpp------------------------------------------*/
#include<iostream>
#include<utilities.h>
using namespace std;
int main(int argc , char *argv[])
{
cout << compare(1,2) << endl;
return 0;
}
The code above is an example from a book. However, it gives errors when I compile the three files:
utilities.h:6:24: fatal error: utilities.cpp: No such file or directory
compilation terminated.
main.cpp:2:22: fatal error: utilities.h: No such file or directory
compilation terminated.
I don't know why I get "No such file or directory"!