-3

I have found strange syntax in some of Aruco files:

vector< cv::Mat > thres_images(n_param1);

Seems like thres_images is function, but if yes then what is vector< cv::Mat > in front of it? It is not declaration nor definition. Later it is used as array:

thres = thres_images[n_param1 / 2];

PS: full code can be found here

Wakan Tanka
  • 7,542
  • 16
  • 69
  • 122
  • 1
    That is simply a vector constructor accepting 1 argument, i.e. it's size. You are crating a `std::vector` called `thres_images` with size `n_param1`. Then you access the middle element of this vector – Miki Aug 24 '16 at 13:28
  • 1
    Looks like a variable definition for me, nothing special. – πάντα ῥεῖ Aug 24 '16 at 13:28
  • 5
    I think you need [a good beginners book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). That's a standard variable declaration calling a specific constructor of the [standard `vector` class](http://en.cppreference.com/w/cpp/container/vector). – Some programmer dude Aug 24 '16 at 13:28
  • Have you come across `std::vector` before? – doctorlove Aug 24 '16 at 13:30
  • nothing weird about this. – bolov Aug 24 '16 at 13:31
  • Ah, now I see. I've never used vector constructor before so this misleads me. Isn't there something like this http://cdecl.org/ for C++ constructions? – Wakan Tanka Aug 24 '16 at 14:21

1 Answers1

2

thres_images is a vector and its ctor is passed n_param1 as initial container size. This ctor is referred to as a fill ctor.

Alexander Balabin
  • 2,055
  • 11
  • 13