I have a class router.cpp
with implementations of dijkstras algorithm called getShortestPath
.
I would like to call this method from another .cpp file called interface.cpp
.
Router.h
public:
Router(vector<double>);
void getShortestPath(...):
I defined starter.h as:
#include "Router.h"
class starter {
public:
static Router r;
static std::string func(std::vector<double> bbox) {
std::string a = "DONE";
return a;
}
};
//EDIT: definition of a static variable must be given outside class declaration
Router r = starter::r;
and interface.cpp where I am trying to call getShortestPath
:
starter starter;
std::vector<double> bbox;
//starter::router =
starter::r.getShortestPath(); // ERROR HERE "undefined reference to 'starter::r'
How should I define router appropriately?
How can I overcome this issue? Any suggestions would be appreciated.
EDIT:
After the helpful comments, kindly find the updated definition of the static variable above.
This leaves me with the same error as before:
undefined reference to starter::r
at starter::r.getShortestPath();