'<' - template mismatch
Hello How are you?
A little help please
I would like to work with the Carray class, but I find it penalizing that I can’t do a printarray on the array manipulated by the class.
So I wanted to make a template function that would have allowed me to do the arrayprint Here is the code
My problem is that I can’t write the declaration of the function
If you can help me with the syntax, or maybe a different solution to have the ArrayPrint of the class?
Thank you
void PrintArray (CArray<T> &array)
CArray<int> my_obj();
PrintArray<int>(my_obj);
void PrintArray (T &array)
PrintArray(array);
Hello How are you?
A little help please
I would like to work with the Carray class, but I find it penalizing that I can’t do a printarray on the array manipulated by the class.
So I wanted to make a template function that would have allowed me to do the arrayprint Here is the code
template <typename T> void PrintArray (CArray<T> &array) { // Obtenir la taille du tableau int size = array.Total (); // Créer un tableau temporaire T array_tmp []; // Redimensionner le tableau temporaire avec la taille du tableau de la classe ArrayResize (array_tmp, size); // Parcourir le tableau avec une boucle for for (int i = 0; i < size; i++) { // Obtenir l'élément à l'index i avec la méthode At T element = array.At (i); // Ajouter l'élément au tableau temporaire array_tmp [i] = element; } // Imprimer le tableau temporaire dans le journal avec la fonction ArrayPrint ArrayPrint (array_tmp); }My problem is that I can’t write the declaration of the function
If you can help me with the syntax, or maybe a different solution to have the ArrayPrint of the class?
Thank you