Vector<int,2> origin;

Write your question here.
The syntax for vector is Vector<int> vector name.
Here what does 2 do in the following command.
Vector<T,2> origin;

Vector<T,2> origin;
That depends on what Vector exactly is.

I would guess that the 2 stands for the number of dimensions (i.e. 2D).
If you're talking about std::vector then you're not allowed to pass a number as a second template argument.

#include <vector>
std::vector<int, 2> origin; // error! 

If you're talking about some class template named Vector that you have created yourself or gotten from a third party library then it is difficult to say for certain without knowing how it's defined but my guess is that it represents a mathematical/physics vector and 2 probably means you want it to be in two dimensions (i.e. contains two numbers).
Last edited on
Thanks for your comments, Yes it is part of openLb, it is hard for me to understand the code since i am new to C++ and the openLb has a lot of library. Do you have any recommendation?
Do you have any recommendation?

Learn C++ with the standard library first.
Understand the Lattice-Bolzmann method (yuk! there are better methods for CFD!) second.

Then play around with the L-B examples (making sure that you can actually compile them).
I believe that
Vector<T,2> origin;

will, storage-wise, behave like
std::vector<T> origin(2);
However, this OLB version probably has quite a lot of convenient geometry-associated methods defined for it, making it behave like a mathematical/geometric vector.

Last edited on
Topic archived. No new replies allowed.