I'm currently learning templates -- & my logic is in a knot with what I am trying to do which is the following:
-Create a function name load
-Accepts a filename (the filename is a text file of integers)
-Open the file
-Create an array(dynamically allocating an array) filling it with the elements read in from the file & returns the array(so that the return type of the array is a pointer to the element type of the array).
So here's what I have, and maybe you can help me see what I'm doing wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//Header file:
#ifndef BUBBLE_SORT_H
#define BUBBLE_SORT_H
#include <iostream>
template <typename T>
void load(std::string filename, T *&arr, int *size);
template <typename T>
void load(std::string filename, T *&arr, int *size) {
T n;
arr = load<int>("myfile.txt", size);
for(int i = 0; i < n; i++)
}
#endif