I have seen a Class like this:
class Vec2D {
int i_;
int j_;
vector<double> vec;
public:
Vec2D(int i, int j): i_(i),j_(j) {vec.assign(i_*j_,0);}
double & operator() (int i, int j){return ver[j_*i+j];} // overloading
double * operator()(){return &(vec[0]); } // ???
};
I understand double & operator()
is for operator overloading.
As for double * operator()(){return &(vec[0]); }
, obviously it is used to return a pointer to the first element, but I don't understand the mechanism, is it an overloading or a function pointer?