Why is feature2D::detect not implemented in source code, but can get the result of feature point detection?

the source file (features2d.cpp):

/* Detects keypoints and computes the descriptors */
void Feature2D::detectAndCompute( InputArray, InputArray,
                                  std::vector<KeyPoint>&,
                                  OutputArray, bool )
{
    CV_INSTRUMENT_REGION();

    CV_Error(Error::StsNotImplemented, "");
}

Why there is no specific implementation here, but can get the result of feature point detection?

that looks like you’re in the interface.

a Feature2D is non-specific. it has no single implementation. it’s a container for implementations to fill with data.

look for derived classes, or classes that use/contain Feature2D. those will actually implement behavior.