I'm having an undefined reference error in my main. Not sure what I'm doing wrong and have tried changing names and moving things around but keep getting the same error. I'm wondering if maybe it's my IDE but really don't know Here's the code:
#include <iostream>
#include "f.h"
#include "g.h"
using namespace std;
int main()
{
F f;
G g;
f.f();
g.g();
return 0;
}
next file:
#ifndef F_H_INCLUDED
#define F_H_INCLUDED
class F
{
public:
void f();
};
#endif
next file:
#ifndef G_H_INCLUDED
#define G_H_INCLUDED
class G
{
public:
void g();
};
#endif
next file:
#include "f.h"
#include <iostream>
void F::f()
{
std::cout << "This was function f!" << std::endl;
}
next file:
#include "g.h"
#include <iostream>
void G::g()
{
std::cout << "This was function g!" << std::endl;
}
edit: so i changed the include from "f.h" and "g.h" to "f.cpp" and "g.cpp" and now it works... can anyone explain why?