What does this mean when the built-in type has brackets with it.
eg. int () or float ()
Is it the default constructor or has a different meaning for the built-in types?
---- ---- edit
To add more context:
In my school textbook for C ++, I am in the chapter on templates. The template used for the demonstration is a Table template (2D array). One of the functions of the Table is a resizing method for resizing the table and is also used in some constructors used for the Table . This constructor and resizing method:
template <typename T> Table<T>::Table<T>(int m, int n) { mDataMatrix = 0; mNumRows = 0; mNumCols = 0; resize(m, n, T()); }
and
template <typename T> void Table<T>::resize(int m, int n, const T& value) { // Destroy the previous data. destroy(); // Save dimensions. mNumRows = m; mNumCols = n; // Allocate a row (array) of pointers. mDataMatrix = new T*[mNumRows]; // Now, loop through each pointer in this row array. for(int i = 0; i < mNumRows; ++i) { // And allocate a column (array) to build the table. mDataMatrix[i] = new T[mNumCols]; // Now loop through each element in this row[i] // and copy 'value' into it. for(int j = 0; j < mNumCols; ++j) mDataMatrix[i][j] = value; } }
In the constructor definition, resizing the third argument is T () (and I assume that T becomes who the specified type for the template was specified).
In the definition for resize, T () is used for the value argument to assign a default value to the elements in the table.
Of some earlier answers, this is zero initialization. I assume this means that the value is 0 for each element of the table (or some equivalent 0 if the type is a string, I think). Is it correct?
c ++
Dr negative
source share