I have to write this function +operator=(source: Array<ElemType, SIZE>): Array<ElemType, SIZE> but I do not know how to start the declaration / or start the function.
NOTE: I have to return a template but I do not know how to do it, Can somebody show me how to start it.
#ifndef CLASS_TEMPLATE_H
#define CLASS_TEMPLATE_H
#include <iostream>
usingnamespace std;
namespace JuanSanchez
{
// This is the template of the Class Array
template<typename T = double, int SIZE = 5>
class Array
{
public:
// Constructor of the array class
Array();
private:
T elements[SIZE];
};
// declaration constructor class array with a template that has no parameter
template<> class Array<> { public: Array(); };
// declaration constructor class array with a template that has two parameters
template<> class Array<double, 10> { public: Array(); };
// Constructor with template non-type argument or the typename is not the same as what
// is declared.
template<typename T, int SIZE>
Array<T, SIZE>::Array()
{
T elements[SIZE] = {0};
cout << "Template with non-type argument or typename is not same as what is declared " << elements[4] << endl;
}
// Constructor with Explicit specialization default arguments
Array<>::Array()
{
cout << "Explicit specialization default arguments" << endl;
}
// constructor with Explicit specialization
Array<double, 10>::Array()
{
cout << "Explicit specialization <double, 10>" << endl;
}
}
#endif