I receive the following error when I try to compile three c++ files with g++ main.cpp
. If I combine them in one file, it works.
main.cpp:(.text+0x10): undefined reference to `Time::Time()'
Time.cpp
#include <iostream>
#include "Time.h"
using namespace std;
Time::Time()
{
a=5;
}
Time.h
#ifndef TIME_H
#define TIME_H
class Time {
public:
Time();
private:
int a;
};
#endif
main.cpp
#include <iostream>
#include "Time.h"
using namespace std;
int main()
{
Time t;
}