I am developing a c++ program for a Calculus homework, but i am getting a compilation error when i declare the "grafico" instance of "Grafico" class inside the "EDO" class. I am not so used to using C++, so could you guys help me find out what i am missing? Am i properly using "this->"?
Here is the main code for the problem (The comments are in portuguese so you can ignore they):
class Grafico {
public:
Grafico(std::vector<double>& x, std::vector<double>& y) {
xValues = x;
yValues = y;
}
~Grafico(){}
void plotar() {
plt::plot(this->xValues, this->yValues, "o-");
plt::title(this->titulo);
plt::show();
}
private:
std::vector<double> xValues, yValues;
const std::string titulo = "Solução Numérica";
};
class EDO {
public:
double f(double x, double y) {
return 2*y/(x+1) + std::pow(x+1, 3);
}
double get_x0() {
return this->x_0;
}
double get_y0() {
return this->y_0;
}
void adicionar_ponto(double x, double y) {
this->x.push_back(x);
this->y.push_back(y);
}
void plotar_grafico() {
this->grafico.plotar();
}
private:
const double x_0=0, y_0=3; // Valores iniciais
std::vector<double> x {this->x_0};
std::vector<double> y {this->y_0}; // Pontos da função resultante
Grafico grafico(this.x,this.y);
};
And here is the error i get when compiling using g++ and c++11:
Aucun commentaire:
Enregistrer un commentaire