Question: I have over 20,000 records that are being exported from a program that look like this:

```
Parent   : 000691195
CUSTNO   : 115225036-AD
COMPANY  : BROOK FURNITURE RENTAL
ADDRESS1 : 100 N FIELD DR
city     : LAKE FOREST
STATE    : IL
ZIP      : 600452580

Parent   : 000691195
CUSTNO   : 116952265-AD
COMPANY  : BROOK FURNITURE RENTAL
ADDRESS1 : 100 N FIELD DR STE 220
city     : LAKE FOREST
STATE    : IL
ZIP      : 600452598

```

I need to transpose them into usable columns and rows, but I have no IDEA how to get it to work from the text file. I have looked at some answers in how to replace the carriage return to a comma but the last piece of data need to NOT have a comma after it to indicate the end of the row and some of the ADDRESS1 fields are empty anyway. 

Any help would be appreciated.

Answer: 
Rather than converting your function to a template, convert your class to a template:

```
template <class T>
class myclass {
private:
    T *data;
public:
    myclass(size_t size) : data(new T[size]) {
    }
    ... // Add copy constructor, assignment operator, and a destructor
        // to properly manage the pointer. See "rule of three" for more info.
};

```

This way the type of array element becomes part of the type of your class, letting your member functions work with the `data` without any additional type casting.

Note that using raw array pointer in the class comes with significant liabilities in terms of memory management. You would be better off with `std::vector<T>`.
Convert your whole class to a templated class

```
template<typename T>
class Container {
public:
    Container() :
        data(NULL)
    {}
    ~Container() {
        if (data) {
            delete [] data;
        }
    }
    T* foo(int size) {
        if (data) {
            delete [] data;
        }
        data = new T[size];
        return data;
    }
private:
    T *data;
};

```