Undefined reference

Hello, I know the code is correct but for some reason when I compile the code it says "[Linker error] undefined reference to 'myFun::add(int,int)'" . I am compiling in Dev c++. Here is my code:
Functions.h
1
2
3
4
5
6
7
8
9
10
11
#ifndef TESTCLASS_H
#define TESTCLASS_H
#include <iostream>
using namespace std;

class myFun
{
      public:
             int add(int x, int y);
};
#endif 

Functions.cpp
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;
#include "Functions.h"

int myFun::add(int x, int y)
{
   return x+y; 
}

text.cpp
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
#include "Functions.h"
int main()
{
   int pause; 
   myFun ignite;
   cout<<ignite.add(2,4);
   cin>>pause;
}


Also I did notice in the file the header file "Functions.h" is saved as a C Header File where the rest of the files are C++ Source File. How do I change Functions.h to a C++ Header File and do I have to change it?
Last edited on
Is "Functions.cpp" linked in your project? Check "Project -> Remove From Project" at the top of the IDE's window. If you do not see it listed the you need to add it with "Project -> Add to Project" which should be right above the other command.

Oh yeah, stop using Dev-C++, it's old and bad and stuff.

EDIT: Another way to do this is to go to: "Window -> List" this will pop-up with the files linked in your project.
Last edited on
That fixed it thanks! What compiler would you suggest using?
This will be the easiest for you to learn if you've already started with Dev-C++: http://wxdsgn.sourceforge.net/?q=node/4

This is a little buggy but a lot less so, and it is up to date.
Topic archived. No new replies allowed.