Oczywiście, masz rację. Zastosowałem powyższe poprawki w swoim głównym kodzie niestety nie przyniosły one oczekiwanego rezultatu, nadal występuje ten sam problem. Wklejam już cały kod bez owijania w bawełnę. Kod jeszcze będzie rozwijany o takie rzeczy jak wyszukiwanie konkretnych wartości w liście itd. Miał to być prymitywny system "wypożyczalni filmów". Pomoże ktoś, bo naprawdę nie wiem czemu jest błąd przy "*f" w baza.cpp "Baza::wypisz_liste_filmow() :((
main.cpp:
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string.h>
#include "naglowek.h"
using namespace std;
int main( void )
{
int wybor1, wybor11, wybor111, wybor2, wybor3, wybor31, wybor32;
Baza baza_wypozyczalnia;
do
{
cout << "1. Wyswietl bazy" << endl;
cout << "2. Klienci" << endl;
cout << "3. Bazy danych" << endl;
cout << "4. Zamknij system" << endl;
cin >> wybor1;
cout << endl;
switch( wybor1 )
{
case 1:
{
cout << "1. Lista filmow" << endl;
cout << "2. Lista osob" << endl;
cout << "3. Wroc" << endl;
cin >> wybor11;
cout << endl;
switch( wybor11 )
{
case 1:
{
cout << "\n\n___________________\n\n";
cout << "\n\n___________________\n\n";
break;
}
case 2:
{
cout << "1. Lista klientow" << endl;
cout << "2. Lista aktorow" << endl;
cout << "3. Wroc" << endl;
cin >> wybor111;
cout << endl;
switch( wybor111 )
{
case 1:
{
cout << "\n\n___________________\n\n";
baza_wypozyczalnia.wypisz_liste_klientow();
cout << "\n\n___________________\n\n";
}
case 2:
{
cout << "\n\n___________________\n\n";
baza_wypozyczalnia.wypisz_liste_aktorow();
cout << "\n\n___________________\n\n";
}
case 3:
{
break;
}
}
} break;
case 3:
{
break;
}
} break;
break;
}
case 2:
{
cout << "1. Dodaj klienta" << endl;
cout << "2. Usun klienta" << endl;
cout << "3. Wypisz ogolna liste klientow" << endl;
cout << "4. Wypisz liste klientow 'po terminie'" << endl;
cout << "5. Dodaj wypozyczenie do klienta" << endl;
cout << "6. Wroc" << endl;
cin >> wybor2;
cout << endl;
switch( wybor2 )
{
case 1:
{
Osoby * k1 = new Klienci( 1, "stach", "stachowiecki", 25.5, 30.5 );
k1->wypelnij();
baza_wypozyczalnia.list_push_front_klienci( k1 );
break;
}
case 2:
{
int x;
cout << "Podaj numer klienta: " << endl;
cin >> x;
baza_wypozyczalnia.usun_klientow( x );
break;
}
case 3:
{
cout << "\n\n___________________\n\n";
cout << "\n\n___________________\n\n";
}
case 4:
{
cout << "\n\n___________________\n\n";
cout << "\n\n___________________\n\n";
}
case 5:
{
}
case 6:
{
break;
}
} break;
}
case 3:
{
cout << "1. Baza filmow" << endl;
cout << "2. Baza aktorow" << endl;
cout << "3. Wroc" << endl;
cin >> wybor3;
cout << endl;
switch( wybor3 )
{
case 1:
{
cout << "1. Dodaj film" << endl;
cout << "2. Usun film" << endl;
cout << "3. Wyszukaj film" << endl;
cout << "4. Wroc" << endl;
cin >> wybor31;
cout << endl;
switch( wybor31 )
{
case 1:
{
Filmy * f1 = new Filmy( 1, "kingkong", 1995, "sensacja" );
f1->wypelnij();
baza_wypozyczalnia.list_push_front_filmy( f1 );
break;
}
case 2:
{
}
case 3:
{
}
case 4:
{
break;
}
}
} break;
case 2:
{
cout << "1. Dodaj aktora" << endl;
cout << "2. Usun aktora" << endl;
cout << "3. Wyszukaj aktora" << endl;
cout << "4. Wroc" << endl;
cin >> wybor32;
cout << endl;
switch( wybor32 )
{
case 1:
{
Klienci * a1 = new Klienci( 1, "test", "test", 1, 1 );
a1->wypelnij();
baza_wypozyczalnia.list_push_front_klienci( a1 );
break;
}
case 2:
{
int x;
cout << "Podaj numer aktora: " << endl;
cin >> x;
baza_wypozyczalnia.usun_aktora( x );
break;
}
case 3:
{
}
}
case 3:
{
break;
}
} break;
}
}
}
} while( wybor1 != 4 );
return( 0 );
}
baza.cpp:
#include <iostream>
#include <fstream>
#include "naglowek.h"
using namespace std;
void Baza::list_push_front_klienci( Osoby * os )
{
CWezel * wezel = new CWezel;
licznik++;
wezel->s = os;
wezel->indeks = licznik;
wezel->nast = head;
head = wezel;
os->pole_lp( licznik );
}
void Baza::usun_klientow( int x )
{
CWezel * iter;
CWezel * tmp;
iter = head;
if( x <= licznik && iter )
{
if( x != 1 )
{
for( int i = 1; i <= x - 2; i++ )
{
iter = iter->nast;
}
tmp = iter->nast;
iter->nast = iter->nast->nast;
delete tmp;
}
else
{
head = iter->nast;
delete iter;
}
}
else
{
cout << "Nie ma tylu produkow!" << endl;
}
}
void Baza::wypisz_liste_klientow()
{
CWezel * wsk;
wsk = head;
while( wsk )
{
wsk->s->pokaz();
wsk = wsk->nast;
}
delete wsk;
}
void Baza::list_push_front_aktorzy( Osoby * os2 )
{
CWezel * wezel = new CWezel;
licznik2++;
wezel->a = os2;
wezel->indeks2 = licznik2;
wezel->nast2 = head2;
head2 = wezel;
os2->pole_lp( licznik2 );
}
void Baza::usun_aktora( int x )
{
CWezel * iter;
CWezel * tmp;
iter = head2;
if( x <= licznik2 && iter )
{
if( x != 1 )
{
for( int i = 1; i <= x - 2; i++ )
{
iter = iter->nast2;
}
tmp = iter->nast2;
iter->nast2 = iter->nast2->nast2;
delete tmp;
}
else
{
head2 = iter->nast2;
delete iter;
}
}
else
{
cout << "Nie ma tyle pozycji!" << endl;
}
}
void Baza::wypisz_liste_aktorow()
{
CWezel * wsk;
wsk = head2;
while( wsk )
{
wsk->a->pokaz();
wsk = wsk->nast2;
}
delete wsk;
}
void Baza::list_push_front_filmy( Filmy * film )
{
CWezel * wezel = new CWezel;
licznikf++;
wezel->f = film;
wezel->indeksf = licznikf;
wezel->nastf = headf;
headf = wezel;
}
void Baza::usun_film( int xf )
{
CWezel * iter;
CWezel * tmp;
iter = headf;
if( xf <= licznikf && iter )
{
if( xf != 1 )
{
for( int i = 1; i <= xf - 2; i++ )
{
iter = iter->nastf;
}
tmp = iter->nastf;
iter->nastf = iter->nastf->nastf;
delete tmp;
}
else
{
headf = iter->nastf;
delete iter;
}
}
else
{
cout << "Nie ma tyle pozycji!" << endl;
cout << endl;
}
}
void Baza::wypisz_liste_filmow()
{
CWezel * wsk;
wsk = headf;
while( wsk )
{
wsk->f->pokaz();
wsk = wsk->nastf;
}
delete wsk;
}
Osoby.cpp:
#include <iostream>
#include <fstream>
#include <string>
#include "naglowek.h"
using namespace std;
Osoby::Osoby( int Nlp, string Nimie, string Nnazwisko )
{
lp = Nlp;
imie = Nimie;
nazwisko = Nnazwisko;
}
Osoby::Osoby()
{
lp = 0;
}
Osoby::~Osoby()
{
;
}
void Osoby::wypelnij()
{
cout << "Podaj imie: " << endl;
cin >> imie;
cout << "Podaj nazwisko: " << endl;
cin >> nazwisko;
}
void Osoby::pokaz( void )
{
cout << lp << endl;
cout << "Imie: " << imie << endl;
cout << "Nazwisko: " << nazwisko << endl;
cout << endl;
}
int Osoby::pole_lp( void )
{
return( lp );
}
void Osoby::pole_lp( int x )
{
lp = x;
}
klienci.cpp:
#include <iostream>
#include <fstream>
#include <string>
#include "naglowek.h"
using namespace std;
Klienci::Klienci( int Nlp, string Nimie, string Nnazwisko, double Ndatawyp, double Ndatazwr )
{
lp = Nlp;
imie = Nimie;
nazwisko = Nnazwisko;
datawyp = Ndatawyp;
datazwr = Ndatazwr;
}
Klienci::~Klienci()
{
;
}
void Klienci::pokaz()
{
cout << lp << endl;
cout << "Imie: " << imie << endl;
cout << "Nazwisko: " << nazwisko << endl;
cout << "Data wypozyczenia: " << datawyp << endl;
cout << "Data zwrotu: " << datazwr << endl;
cout << endl;
}
void Klienci::wypelnij()
{
cout << "Podaj Imie: " << endl;
cin >> imie;
cout << "Podaj Nazwisko: " << endl;
cin >> nazwisko;
cout << "Podaj date wypozyczenia: " << endl;
cin >> datawyp;
cout << "Podaj date zwrotu: " << endl;
cin >> datazwr;
cout << endl;
}
aktorzy.cpp:
#include <iostream>
#include <fstream>
#include <string>
#include "naglowek.h"
using namespace std;
Aktorzy::Aktorzy( int Nlp, string Nimie, string Nnazwisko )
{
lp = Nlp;
imie = Nimie;
nazwisko = Nnazwisko;
}
Aktorzy::~Aktorzy()
{
;
}
void Aktorzy::pokaz()
{
cout << lp << endl;
cout << "Imie: " << imie << endl;
cout << "Nazwisko: " << nazwisko << endl;
cout << endl;
}
void Aktorzy::wypelnij()
{
cout << "Podaj Imie: " << endl;
cin >> imie;
cout << "Podaj Nazwisko: " << endl;
cin >> nazwisko;
cout << endl;
}
naglowek.cpp:
#ifndef NAGLOWEK_H_INCLUDED
#define NAGLOWEK_H_INCLUDED
#include <string>
class Filmy
{
protected:
int lp;
std::string tytul;
int rok;
std::string gatunek;
public:
Filmy();
Filmy( int Nlp, std::string Ntytul, int Nrok, std::string Ngatunek );
void wypelnij();
void pokaz();
~Filmy();
int pole_lp( void );
void pole_lp( int );
};
class Osoby
{
protected:
int lp;
std::string imie;
std::string nazwisko;
public:
Osoby();
Osoby( int Nlp, std::string Nimie, std::string Nnazwisko );
virtual void wypelnij();
virtual void pokaz( void );
~Osoby();
int pole_lp( void );
void pole_lp( int );
};
class Aktorzy
: public Osoby
{
public:
Aktorzy( int Nlp, std::string Nimie, std::string Nnazwisko );
void pokaz();
void wypelnij();
~Aktorzy();
};
class Klienci
: public Osoby
{
private:
double datawyp;
double datazwr;
public:
Klienci( int Nlp, std::string Nimie, std::string Nnazwisko, double Ndatawyp, double Ndatazwr );
void pokaz();
void wypelnij();
~Klienci();
};
struct CWezel
{
CWezel * nast;
CWezel * nast2;
CWezel * nastf;
Osoby * s;
Osoby * a;
Filmy * f;
int indeks;
int indeks2;
int indeksf;
CWezel()
{
nast = NULL;
nast2 = NULL;
nastf = NULL;
s = NULL;
a = NULL;
f = NULL;
indeks = 0;
indeks2 = 0;
indeksf = 0;
}
};
class Baza
{
public:
CWezel * thead;
CWezel * tlast;
CWezel * head;
CWezel * last;
CWezel * head2;
CWezel * last2;
CWezel * headf;
CWezel * lastf;
int licznik;
int licznik2;
int licznikf;
Baza()
{
head = NULL;
last = NULL;
licznik = 0;
head2 = NULL;
last2 = NULL;
licznik2 = 0;
headf = NULL;
lastf = NULL;
licznikf = 0;
}
void list_push_front_klienci( Osoby * );
void usun_klientow( int x );
void wypisz_liste_klientow();
void list_push_front_aktorzy( Osoby * );
void usun_aktora( int x );
void wypisz_liste_aktorow();
void list_push_front_filmy( Filmy * );
void usun_film( int x );
void wypisz_liste_filmow();
};
#endif
Filmy.cpp:
#include <iostream>
#include <fstream>
#include <string>
#include "naglowek.h"
using namespace std;
Filmy::Filmy( int Nlp, string Ntytul, int Nrok, string Ngatunek )
{
lp = Nlp;
tytul = Ntytul;
rok = Nrok;
gatunek = Ngatunek;
}
Filmy::Filmy()
{
lp = 0;
}
Filmy::~Filmy()
{
;
}
void Filmy::wypelnij()
{
cout << "Podaj tytul: " << endl;
cin >> tytul;
cout << "Podaj rok produkcji: " << endl;
cin >> rok;
cout << "Podaj gatunek: " << endl;
cin >> gatunek;
cout << endl;
}
void Filmy::pokaz()
{
cout << lp << endl;
cout << "Tytul filmu: " << tytul << endl;
cout << "Rok: " << rok << endl;
cout << "Gatunek: " << gatunek << endl;
cout << endl;
}
int Filmy::pole_lp( void )
{
return( lp );
}
void Filmy::pole_lp( int x )
{
lp = x;
}
Kod błędu:
||=== Build: Debug in Wypozyczalnia 2 (compiler: GNU GCC Compiler) ===|
obj\Debug\baza.o||In function `ZN4Baza19wypisz_liste_filmowEv':|
D:\Dokumenty\Code Blocks Programy\Wypozyczalnia 2\baza.cpp|183|undefined reference to `Filmy::pokaz()'|
obj\Debug\main.o||In function `main':|
D:\Dokumenty\Code Blocks Programy\Wypozyczalnia 2\main.cpp|161|undefined reference to `Filmy::Filmy(int, std::string, int, std::string)'|
D:\Dokumenty\Code Blocks Programy\Wypozyczalnia 2\main.cpp|162|undefined reference to `Filmy::wypelnij()'|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|