![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Регистрация: 03.05.2010
Сообщений: 3
|
![]()
Помогите исправить ошибку:
#include<iostream> using namespace std; template<class T> class spisok { spisok * last; spisok * first; spisok *pred; spisok *next; T data; public: void add(T); void del(); void print(); friend ostream& operator <<(ostream&,spisok); friend bool operator ==(spisok&,spisok&); }; template<class T> void spisok<T>::add(T data) { spisok *p=new spisok; if(last==NULL) p->pred=NULL; else { last->next=p; p->pred=last; } last=p; p->next=NULL; p->data=data; } template<class T> void spisok<T>: ![]() { last=last->pred; last->next=NULL; } template<class T> void spisok<T>: ![]() { spisok *p=first; while(p) { cout<<p->data<<endl; p=p->next; } cout<<endl; } template<class T> ostream& operator <<(ostream& out,spisok<T> s) { spisok *p=s.first; while(p) { out<<p->data<<endl; p=p->next; } out<<endl; return out; } template<class T> bool operator ==(spisok<T> &A,spisok<T> &B) { spisok *a=A.first; spisok *b=B.first; int k1=0,k2=0; while(a) { k1++; a=a->next; } while(b) { k2++; b=b->next; } if(k1==k2) return true; else return false; } void main() { int k1,k2; spisok <int> A; int di; spisok <char> B; char dc; cout<<"vvedite razmer 1 spiska"<<endl; cin>>k1; cout<<"vvedite elementi 1 spiska(int)"<<endl; for(int i=0;i<k1;i++) { cout<<i+1<<" element:"; cin>>di; A.add(di); } cout<<"vvedite razmer 1 spiska"<<endl; cin>>k2; cout<<"vvedite elementi 2 spiska(char)"<<endl; for(int i=0;i<k2;i++) { cout<<i+1<<" element:"; cin>>dc; B.add(dc); } A.print(); cout<<A; } |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
двусвязный список | klykovka | Помощь студентам | 8 | 22.05.2010 18:58 |
Наследование класса "Двунаправленный список" | JeyKip | Общие вопросы C/C++ | 0 | 11.01.2010 15:52 |
Двусвязный список | kruserg | Паскаль, Turbo Pascal, PascalABC.NET | 1 | 28.04.2009 10:37 |