Witam,
mam następujący problem - mam dwie kilka klas, w tym TripList oraz ClientList, które przechowują listy obiektów z klas Trip oraz Client. Chciałbym podczas dodwania Clienta sprawdzić czy jeden z jego parametrów nie jest przypadkiem równy parametrowi Trip.
Oto część pliku ClientList:
#include"ClientList.h"
#include"TripList.h"
#include<iostream>
#include<cstring>
using namespace std;
ClientList::ClientList()
{
head=0;
}
ClientList::~ClientList()
{
Client * ptr;
ptr = NULL;
while(head != NULL){
cout << "Deleting... current name: " << head->getLNAME() << endl;
ptr = head;
head = head->getNEXT();
delete ptr->getNAME();
delete ptr->getLNAME();
delete ptr;
}
if(head == NULL){
cout <<"The list is EMPTY" << endl;
}
}
void ClientList::insert_client(int i, char *n, char *ln, double p, double c, int idt)
{
Client *nowy;
nowy = new Client(i,n,ln,p,c,idt);//arugmenty klasy
Trip *ptr;
ptr=head;
int spr=1;
while(ptr)
{
if(ptr->getID()==idt)
{
spr=0;
}
}
if(spr==0)
cout<<"There is no such ID "<<endl;
else
if(head==0)
head=nowy;//first element insertion.
else
{
Client *temp=head;
while(temp->getNEXT())//next element.
{
temp=temp->getNEXT();
}
temp->setNEXT(nowy);
nowy->setNEXT(0);
}
}
i część pliku TripList:
#include "TripList.h"
TripList::TripList()
{
head=0;
}
TripList::~TripList()
{
Trip * ptr;
ptr = NULL;
while(head != NULL){
cout << "Deleting... current name: " << head->getNAME() << endl;
ptr = head;
head = head->getNEXT();
delete ptr;
}
}
Przy kompilacji wyskakuje mi błąd:
[Error] cannot convert 'Client*' to 'Trip*' in assignment
Wie ktoś jak to mogę rozwiązać? Rozumiem czemu taki błąd się pojawia ale nie za bardzo wiem jak to mogę ominąć.