vendredi 21 avril 2017

What's the point of having this unused function Init

New to C++, have a code with unused function Init, what's the point of having this if we never used it?

Header file: "KFilter.h"

#include "Eigen/Dense"
class KFilter {
  public:
    Eigen::VectorXd x_;
    KFilter();
    virtual ~KFilter();
    void Init(Eigen::VectorXd &x_in);
    void Predict();
}

cpp file: "KFilter.cpp"

#include "KFilter.h"
using Eigen::MatrixXd;
using Eigen::VectorXd;
KFilter::KFilter() {}
KFilter::~KFilter(){}
void KFilter::Init(VectorXd &x_in) {
    x_ = x_in;
}
void KFilter::Add_one() {
    x_ += 1;
}

Later in the main.cpp, I see someone use one object of this KFilter class.

KFilter ekf_;
ekf_.x_ = VectorXd(4);
ekf_.x_ < 1, 1, 1, 1;
ekf_.Add_one();

I guess it is kind of like setter and getter, but why Init? I couldn't find this kind of usage on the textbook of C++. Or it is because of the pointer used here?

Aucun commentaire:

Enregistrer un commentaire