template <typename T> class Array3{ template <class> friend class Array3;private: T d[3];public: Array3<T>(const T x, const T y, const T z) { this->d[0] = x; this->d[1] = y; this->d[2] = z; } inline const T operator [](const int i) const { return this->d[i]; } template <typename TT> inline Array3<T> operator *(Array3<TT> const &a) { return Array3<T>(this->d[0] * a[0], this->d[1] * a[1], this->d[2] * a[2]); } inline Array3<T> & operator =(const T &a) { return (*this = Array3<T>(a, a, a)); }};
template <class T>template <class TT>Array3<T> Array3<T>::operator *(Array3<TT> const &a){ return Array3<T>(this->d[0] * a[0], this->d[1] * a[1], this->d[2] * a[2]);}
C++ (Qt)template <typename T>class Array3{ template <class> friend class Array3; template<class TT, class TTT> friend Array3<TT>& operator*(Array3<TT>& , const Array3<TTT>& ); private: T d[3]; public: Array3<T>(const T x = T(), const T y = T(), const T z = T()) { this->d[0] = x; this->d[1] = y; this->d[2] = z; } inline const T operator [](const int i) const { return this->d[i]; } // template <typename TT> inline Array3<T> operator *(Array3<TT> const &a)// {// return Array3<T>(this->d[0] * a[0], this->d[1] * a[1], this->d[2] * a[2]);// } inline Array3<T> & operator =(const T &a) { return (*this = Array3<T>(a, a, a)); }}; template<class T, class TT>Array3<T>& operator*(Array3<T>& t, const Array3<TT>& tt ){ t.d[0] = t[0]*tt[0]; t.d[1] = t[1]*tt[1]; t.d[2] = t[2]*tt[2]; return t;}
template <typename T> class Array3{ template <class> friend class Array3;private: T d[3];public: Array3<T>(const T x, const T y, const T z); inline const T operator [](const int i) const; template <typename TT> inline Array3<T> operator *(Array3<TT> const &a); inline Array3<T> & operator =(const T &a);};
export template <typename T> Array3<T>::Array3(const T x, const T y, const T z){ this->d[0] = x; this->d[1] = y; this->d[2] = z;}export template <typename T> const T Array3<T>::operator [](const int i) const{ return this->d[i];}export template <typename T> template <typename TT> inline Array3<T> Array3<T>::operator *(Array3<TT> const &a){ return Array3<T>(this->d[0] * a[0], this->d[1] * a[1], this->d[2] * a[2]);}export template <typename T> inline Array3<T> & Array3<T>::operator =(const T &a){ return (*this = Array3<T>(a, a, a));}
C++ (Qt)// Array3.h...#include "Array3.cpp"
template <typename T> void foo(){ T t;}Далее где-то использование:foo();