Given: the number N and the sequence a1, a2, ... aN
Create a class template that generates dynamic one-dimensional arrays with elements of various types (real, integer, character, etc.). The data type and result are parameters in relation to the class, the program must have initialization methods, a constructor, a destructor, a method for viewing the values of the created array, according to the specified algorithm.
(a1*a1), (a1*a2), …, (a1*aN); Code
#include "stdafx.h" #include "iostream" using namespace std; template <typename T> class Mas { private: TN; T* mas; public: void set(TN); void print(); }; template <typename T> Mas<T>::Mas(TN) { mas = new T [N]; for(int i(0);i<=N;i++) { cin>>mas[i]; } } template <typename T> Mas<T>::~Mas() { delete [] mas; } template <typename T> Mas<T>::Mas() {} template <typename T> void Mas<T>::set(TN) { mas = new T [N]; for(int i(0);i<=N;i++) { cin>>mas[i]; } }; template <typename T> void Mas<T>::print() { for(int i(0);i<=N;i++) { cout<<mas[i] = mas[1]*mas[i]; } } int _tmain(int argc, _TCHAR* argv[]) { Mas<int> a; a.set(3); a.print(); return 0; } It produces errors:
Ошибка 1 error C2039: {ctor}: не является членом"Mas <T>" c: \ users \ user \ desktop \ dz 6 \ dz 6 \ dz 6.cpp 33 1 DZ 6
Ошибка 2 error C2039: {dtor}: не является членом"Mas <T>" c: \ users \ user \ desktop \ dz 6 \ dz 6 \ dz 6.cpp 40 1 DZ 6
Ошибка 3 error C2039: {ctor}: не является членом"Mas <T>" c: \ users \ user \ desktop \ dz 6 \ dz 6 \ dz 6.cpp 44 1 DZ 6
How to get rid of errors, and did I solve the problem correctly?