Показать сообщение отдельно

Шаблоны классов
  #1  
Старый 29.11.2008, 18:35
A-Spt_N(o)
Познающий
Регистрация: 07.04.2007
Сообщений: 48
С нами: 10050617

Репутация: 8
По умолчанию Шаблоны классов

Готовлю защиту по лабораторной работе...
не могу понять в чем ошибка:
Код:
#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];
}

Последний раз редактировалось scrat; 30.11.2008 в 12:37..
 
Ответить с цитированием