I also think it should work!
Yes, of course, here they are...
I just noticed that I forgot something: Fuction is designed as an abstract class (then of "type" Function I have FLineare, FExponential...). Maybe this is the problem, I still don't have very clear what i can do with abstract classes..
Code:
#ifndef Funzione_HH
#define Funzione_HH
#include "Dato.hh"
#include <vector>
#include <iostream>
using namespace std;
class Function
{
protected:
vector<Dato> a;
double chi;
public:
Function();
Function(vector<Dato> coeff,double c);
virtual ~Function(){};
//METODI;
virtual double YValue(double x)=0;
vector<Dato> Coefficients();
double get_value();
bool operator<(Function f1);
struct Compare {
bool operator ()(Function *f1, Function *f2) { return *f1 < *f2; }
};
};
# endif
Code:
#include "Function.hh"
using namespace std;
Function::Function()
{}
Function::Function(vector<Dato> coeff,double c)
{
a=coeff;
chi=c;
}
vector<Dato> Function::Coefficients()
{
return a;
}
double Function::get_value()
{
return chi;
}
bool Function::operator<(Funzione& f1)
{
bool b;
b= this->get_value() < (f1.get_value());
return b;
}
And in the end the main
Code:
int main{
vector<Function*> functions;
// calculations to fill the vector..
std::sort(functions.begin(),functions.end(),Compare());
}
The only error i get when i compile is "main.cpp: Compare was not declared in this scope"..