Yes, this is quite easy to accomplish. You just call the function the you do the actual implementation in from the other one. That would look like
template<typename _T>
class array {
public:
_T operator+(_T concatinate_operand) { return append(concatinate_operand); } // concatinate to the array
_T append(_T concatinate_operand) { /*actual logic here*/ }
};
Do note that if T
is large then passing it by value and getting a copy will hurt the performance. If you use references like
template<typename _T>
class array {
public:
_T& operator+(const _T& concatinate_operand) { return append(concatinate_operand); } // concatinate to the array
_T& append(const _T& concatinate_operand) { /*actual logic here*/ }
};
You will avoid unnecessary copies.