I'm doing an assignment here... Up until now, I've only seen examples with 1 header for each class. But in this assignment, there are multiple classes in the provided header!
Others.h
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef OTHERS_H
#define OTHERS_H
class Date{
...
};
class Time{
...
};
#endif
So I decided to create a cpp file for each class.
Date.cpp
1 2 3
#include "Others.h"
Date::Date(){...}
Time.cpp
1 2 3
#include "Others.h"
Time::Time(){...}
main.cpp
1 2 3 4 5 6
#include "Others.h"
usingnamespace std;
int main()
{...
return 0;
}
But I get an error when I run my program at the line where there is --#include "Others.h"-- from the Date.cpp and Time.cpp.
I don't know if the error is because of my code, or because of Eclipe (which is giving a headache).
I didn't bother putting all the code since I believe it's irrelevant, but I will if it's needed. Thank you for the help!
makefile:44 : recipe for"TP1_v1" target failed
collect2: error: ld returned 1 exit status
make: *** [TP1_v1] Error1
That's the error when I build the project. When I comment the --#include "Others.h"-- line from the Date.cpp and Time.cpp, I can build and run the program. But that also means I can't define the methods...
I know in Visual Studio I have to include stdafx.h* in every .cpp file for the compile to work.
It is the first I have heard of Mars Eclipse, but just thinking that there might be a header file or two that might need to be included in the Date.cpp and Time.cpp files.