0

I have a very simple test_planner.h file:

class TestPlanner
{
public:
 double GetTheSum(double n1, double n2) {return n1 + n2;}
};

which works well when I call the function "GetTheSum" from GoogleTest.

Now I want to split this file to a .h and a .cpp file.

test_planner.h:

class TestPlanner
{
public:
 double GetTheSum(double n1, double n2);
};

and a respective test_planner.cpp file in the same folder:

#include "test_planner.h"

double TestPlanner::GetTheSum(double n1, double n2)
{
  return n1 + n2;
}

If I run the same GoogleTest now I receive an error message to an "undefined reference to `TestPlanner::GetTheSum(double, double)'". I think my mistake must be in the linking of the two files but I cannot figure out what I did wrong. The problem is even to simple to find similar problems in the Q&A search.

0 Answers0