A-Spt_N(o)
29.11.2008, 18:35
Готовлю защиту по лабораторной работе...
не могу понять в чем ошибка:
#include <assert.h>
#include <iostream>
#include "template.h"
using namespace std;
// ОШИБКА В ЭТИХ СТРОЧКАХ!!!
template class ARRAY<int, int, int>;
template class ARRAY<double, int, int>;
// Конструктор
template <class Type, int low, int hight>
ARRAY<Type, low, hight>::ARRAY()
{ // Забиваем массив нулями
for( int i = low; i <= hight; i++ ) { arr[i] = 0; }
}
// Деструктор
template <class Type, int low, int hight>
ARRAY<Type, low, hight>::~ARRAY(){}
// Поместить елемент в массив
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::PUT(Type num, int pos)
{
if( low <= pos && pos <= hight ) { arr[pos] = num; }
else cout << "ERROR POSITION!!!" << endl;
}
// Удалить елемент из массива
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::PUSH( int pos )
{
if( low <= pos && pos <= hight ) { arr[pos] = 0; }
else cout << "ERROR POSITION!!!" << endl;
}
// Печать массива
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::print() const
{
cout << "Array: \t";
// Выводим массив
for (int i = low; i < hight; i++) { cout << "\t" << arr[i] << " "; }
cout << endl << "index_x: " << x // Вывод нижней границы
<< endl << "index_y: " << y // Вывод верхней границы
<< endl << endl;
}
// Перегруженная операция индексации
template <class Type, int low, int hight>
Type &ARRAY<Type, low, hight>::operator[]( int subscript )
{
// Проверка ошибочного выхода индекса из диапозона
assert( low <= subscript && subscript < hight );
return arr[subscript];
}
не могу понять в чем ошибка:
#include <assert.h>
#include <iostream>
#include "template.h"
using namespace std;
// ОШИБКА В ЭТИХ СТРОЧКАХ!!!
template class ARRAY<int, int, int>;
template class ARRAY<double, int, int>;
// Конструктор
template <class Type, int low, int hight>
ARRAY<Type, low, hight>::ARRAY()
{ // Забиваем массив нулями
for( int i = low; i <= hight; i++ ) { arr[i] = 0; }
}
// Деструктор
template <class Type, int low, int hight>
ARRAY<Type, low, hight>::~ARRAY(){}
// Поместить елемент в массив
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::PUT(Type num, int pos)
{
if( low <= pos && pos <= hight ) { arr[pos] = num; }
else cout << "ERROR POSITION!!!" << endl;
}
// Удалить елемент из массива
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::PUSH( int pos )
{
if( low <= pos && pos <= hight ) { arr[pos] = 0; }
else cout << "ERROR POSITION!!!" << endl;
}
// Печать массива
template <class Type, int low, int hight>
void ARRAY<Type, low, hight>::print() const
{
cout << "Array: \t";
// Выводим массив
for (int i = low; i < hight; i++) { cout << "\t" << arr[i] << " "; }
cout << endl << "index_x: " << x // Вывод нижней границы
<< endl << "index_y: " << y // Вывод верхней границы
<< endl << endl;
}
// Перегруженная операция индексации
template <class Type, int low, int hight>
Type &ARRAY<Type, low, hight>::operator[]( int subscript )
{
// Проверка ошибочного выхода индекса из диапозона
assert( low <= subscript && subscript < hight );
return arr[subscript];
}