In my program that uses separate compilation, the only problem I have left is a linker error. To see if it was just a syntax error somewhere obscure, I made a simple "hello world" program that uses separate compilation. I get the same error. The code is below. If someone knows what is wrong, that would be awesome if they could help.
The header file:
//file name: Hello.h
#ifndef HELLO_H
#define HELLO_H
#include <iostream>
using namespace std;
class Hello
{
public:
Hello(int x);
};
#endif //HELLO_H
The implementation file:
//file name: Hello.cpp
#include <iostream>
#include "Hello.h"
using namespace std;
Hello::Hello (int x)
{
cout << "Hello world";
}
The application file:
//File name: HelloApp.cpp
#include <iostream>
#include "Hello.h"
using namespace std;
int main()
{
char b;
cout << "Press a key to test: ";
cin >> b;
Hello testing(b);
return 0;
}
I don't know why, but the error I get is " [Linker error] undefined reference to `Hello::Hello(int)' ". Please help. Thanks.