I am moving to C++ from a Delphi scenario and I am trying to convert the projects to C++. If you look at main.cpp
you can see:
#include<iostream>
#include "eqsecdeg.h"
int main() {
double a, b, c;
std::cin >> a;
std::cin >> b;
std::cin >> c;
equations::eqSecDeg solver(a, b, c);
std::cout << solver.getDelta();
return 0;
}
And the file called eqsecdeg.h
has this kind of content:
#ifndef EQUATIONS_H
#define EQUATIONS_H
#include<vector>
#include<complex>
namespace equations {
//solve second degree equation
class eqSecDeg {
private:
double a, b, c, delta;
double getDelta(double a, double b, double c);
std::vector<double> solArray;
public:
eqSecDeg(const double valA, const double valB, const double valC);
double getDelta();
std::string getDerivative();
std::vector<double> getSolutions();
};
//help methods for output
double fractionToDecimal(const std::string& value);
std::string decimalToFraction(const double x);
}
#endif
I have read this so many times and googled a solution, but I had no luck. When I give a g++ -std=c++14 main.cpp
in my linux shell I have this error:
main.cpp:(.text+0x72): undefined reference to equations::eqSecDeg::eqSecDeg(double, double, double)
main.cpp:(.text+0x7e): undefined reference to equations::eqSecDeg::getDelta() collect2: error: ld returned 1 exit status
Any idea? I really cannot understand where this code is wrong. I put the include to the header file, the correct namespace and I am creating a local object in the standard way. Any typing error?
Note: if needed this is the implementation of the header (called eqsecdeg.cpp)