Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- // OBIEKT LISTA DONE
- // operator wejscia dodaje 1 element, wyjscia wypisuje wszystkie el NOT DONE
- // konstruktor, destruktor, konstruktor kopiujący NOT DONE
- // + do listy dopisuje na końcu drógą NOT DONE
- // =, ==, != NOT DONE
- class List;
- class Element;
- class Element{
- friend ostream & operator<< (ostream & s1, List & o1);
- friend istream & operator>>(istream & s1, List & o1);
- public:
- int war;
- class Element *next;
- Element(int wart){
- war = wart;
- next= NULL;
- }
- };
- class List{
- friend ostream & operator<< (ostream & s1, List & o1);
- friend istream & operator>>(istream & s1, List & o1);
- class Element *pierwszy;
- public:
- List(){
- pierwszy=NULL;
- }
- ~List(){
- while (pierwszy!=NULL){
- if (pierwszy->next != NULL){
- class Element *nowy=pierwszy->next;
- delete pierwszy;
- pierwszy = nowy;
- }
- else{
- delete pierwszy;
- }
- }
- }
- List(int war){
- pierwszy = new class Element(war);
- }
- };
- ostream & operator<< (ostream & s1, List & o1){
- if (o1.pierwszy!=NULL){
- }
- return s1;
- }
- istream & operator>>(istream & s1, List & o1){
- int zmienna;
- s1>>zmienna;
- Element dodaj(zmienna);
- if (o1.pierwszy == NULL){
- o1.pierwszy = &dodaj;
- }
- else{
- class Element *nowy;
- nowy=o1.pierwszy->next;
- while (nowy->next != NULL){
- nowy=nowy->next;
- }
- nowy->next=&dodaj;
- }
- return s1;
- }
- int main(){
- List lista;
- Element zm(3);
- cin >> lista;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement