0

I need to create a vector inside a template class as follow:

template <typename Float>
class Mat
{
public:
    std::vector<Float> P(2);
};

and in the main function :

int main()
{
  Mat<double> M;
  M.P[0] = 1;
}

However, during the compilation I get this error:

C3867 'Mat::P': non-standard syntax; use '&' to create a pointer to member func.

Do you have any idea what is the problem?

user3687267
  • 21
  • 1
  • 6
  • 2
    You mean `std::vector P = std::vector(2);` ? Or just write Mat constructor, then you can use `Mat(): P(2) { }` syntax – pptaszni Jun 30 '22 at 14:28
  • std::vector P = std::vector(2); actually worked !!! I don't know ht since it is not needed outside a class ! – user3687267 Jun 30 '22 at 14:33

0 Answers0