Is this the same? (vectors notation)

Is the same to write:

(1) mesh electrodeMesh(10e-9,4,10);

than to write:

(2) mesh electrodemesh = {10e-9,4,10):

I understand that BOTH (1) and (2) are vectors, right? You can initialize a variable doing, for example:

int number=10; and int number(10)

Is this the same?
What is mesh? We can't answer without knowing that.

Also, Google-search "C++ uniform initialization".
Last edited on
@L B mesh is a class (sorrty for responding so late but I'm learning c++ and wanted to know more before responding again..!)

I've understood that mesh electrodeMesh(10e-9,4,10); is the same than mesh electrodeMesh={10e-9,4,10};

Now my doubt is, how can you use different constructors? The program knows which one to use because of the number and types of parameters used? (I say this because I suppose that mesh electrodeMesh(10e-9,4,10); refers to the 4th constructor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class mesh
{
public:
        //! Constructor
        /*!
        * Default constructor for mesh.
        * @param nNodes[] is a vector with the number of nodes in the x, y, or z direction.
        */
	mesh();
	mesh(vector<unsigned int>& nNodes, unsigned int nNeighbours, const vector<double> &dimensions);
	mesh(unsigned int nx);
    mesh(double length, unsigned int nDecades, unsigned int pointsPerDecade);
	mesh(double length, unsigned int nx);
    mesh(double lenght, vector<double> xpos);

        //!Destructor
	~mesh();
        //!Copy constructor
	mesh(const mesh & _mesh);

[...]
Yes, if you are familiar with function overloading you will realize that constructor overloading works the same way.

By the way, there are some minor differences between using the constructor with parenthesis vs using the constructor with curly braces vs using the = sign, but I won't go into too much detail because it's very technical and differs between C++03 and C++11.
Thank you @L B..!
Topic archived. No new replies allowed.