I am trying to calculate the partial derivatives of the function f(x,y)=x+y w.r.t x and y at the point (3, 2). I wrote the code but it is giving me an error called Segmentation fault (core dumped). I don't what that is. Can anyone please point out what is wrong in this?
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
class Der{
private:
    double f;  // function value at x
    vector <double> df; // derivative of function at x
    
public:
    Der();
    Der(vector <double>* v);
    Der operator+(Der); // f + g
    
    void print();
    
};
Der :: Der(){}
Der :: Der(vector <double>* v){
    this->f = v->at(0);
    for(int i=1; i < v->size(); i++){
        this -> df[i-1] = v->at(i);
    }
}
Der Der :: operator+(Der g){
    Der h;
    h.f = this->f + g.f;
    for(int i=0; i< df.size(); i++){
        h.df[i] = this->df[i] + g.df[i];
    }
    return h;
}
void Der :: print(){
    cout<<"Function value at given point is : "<<f<<endl;
    for(int i=0; i< df.size(); i++){
    cout<<"Derivative at given point is : "<<df[i]<<endl;
    }
}
int main()
{
    Der f;
    vector <double> t {3,1,0};
    vector <double> k {2,0,1};
    Der x(&t),y(&k);
    
    f = x+y;
    f.print();
}
Thank you very much!
 
    