I would like to create a class that has a function that saves the data sent to it in a text file. The data that can be transferred to it, can be similar to std::string, int, double, float, unsigned intetc., and also can be: std::vector<T>, T[]and std::vector<std::vector<T>>, T[][].
Now, obviously, if it is an array, I will need to iterate over it to send the data to a text file.
I was thinking about using patterns, but I'm not sure how to make arrays.
Is that the way?
class CMyClass
{
template<typename T>
void SaveData(T data);
void SaveData(std::vector<T> data);
void SaveData(std::string data);
void SaveData(T* data);
void SaveData(std::vector<std::vector<T>> data);
void SaveData(T** data);
};
I assume that the code for std::stringwill be the same as the code for std::vector<T>, provided that it Tis a built-in type (e.g., intor floator something else).
SaveData(...) ?