Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей.
Здесь обсуждаются безопасность, программирование, технологии и многое другое.
Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz

29.11.2008, 18:35
|
|
Познающий
Регистрация: 07.04.2007
Сообщений: 48
Провел на форуме: 199652
Репутация:
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..
|
|
|
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|