when trying to compile a .cpp file called rat with a .h file called normalize which is located in a different folder (rat.h is in the same folder as rat.cpp) , I'm typing
g++ -I/opt/cis/include/ -I/opt/cis/lib/ rat.cpp
I have included an int main () in the .cpp file itself, and have completely commented out the inner workings of the .h file and the .cpp file just to try to compile correctly.
The .h file (commented items not included)
1 #ifndef RAT_H
2 #define RAT_H
3 #include <iostream>
4 #include <string>
5
6 class Rat {
7 friend std::ostream &operator<<(std::ostream &, const Rat &);
8 friend std::istream &operator>>(std::istream &, Rat &);
9 private:
10 double n,d;
11 public:
12 Rat(): n(0), d(1) {}
13 };
14. #endif
The .cpp file
1 #include <iostream>
2 #include <cstdlib>
3 #include <string>
4 #include <sstream>
5 #include "rat.h"
6 #include "normalize.h"
7 using namespace std;
8 #ifdef TEST_RAT
9 int main() {};
10 #endif
What am I doing incorrectly? Sorry if it is obvious.