Mam klase Rental, ktora przedstawia sie nastepujaco :
#ifndef RENTAL_H
#define RENTAL_H
#include "Client.h"
#include "Vehicle.h"
#include <ctime>
#include <string>
//deklaracja wyprzedzajaca
class Vehicle;
class Client;
class Rental
{
private:
int daysOfRent;
double costOfRent;
Vehicle* vehicle;
Client* client;
public:
Rental();
Rental(double costOfRent, Vehicle* vehicle, Client* client);
int getDaysOfRent();
double getCostOfRent();
std::string showDetails();
virtual ~Rental();
};
#endif // RENTAL_H
oraz klase Klienta i Pojazdu :
#ifndef CLIENT_H
#define CLIENT_H
#include <string>
#include <vector>
//deklaracja wyprzedzajaca
class ClientType;
class Rental;
class Client
{
private:
std::string name;
std::string surname;
double balance;
double discount;
ClientType *clientType;
public:
Client();
Client(std::string name, std::string surname, double balance,double discount, ClientType *client);
std::string getName() const;
std::string getSurname() const;
double getBalance();
double getDiscount();
std::string toString() ;
void getTypeOfClient();
virtual ~Client();
};
#endif // CLIENT_H
#ifndef BICYCLE_H
#define BICYCLE_H
#include "Vehicle.h"
class Bicycle : public Vehicle
{
private:
public:
Bicycle();
Bicycle(std::string model);
std::string toString();
double getPriceRent();
double getBasePrice();
virtual ~Bicycle();
};
#endif // BICYCLE_H
problem wystepuje w momencie wywolania metody klasy Rental showDetails(), main wyglada tak :
int main()
{
Vehicle *ptr = new Bicycle("Skladak");
PremiumClient premium;
Client Mirek ("Mirek", "Swistak", 0, 0, &premium);
cout<<Mirek.toString()<<endl;
cout<<ptr->toString()<<endl;
Rental rent(10, ptr, &Mirek);
cout<<rent.showDetails()<<endl;
return 0;
}
Natomiast metoda showDetails() przedstawia sie nastepujaco :
std::string Rental::showDetails()
{
std::string content(client -> toString() + " " + vehicle->toString() );
return content;
}
std::string Client::toString() {
std::string content(getName() + " " + getSurname() );
return content;
}
std::string Bicycle::toString() const
{
std::string string(getModel());
return string;
}
Kompilator nie zglasza zadnych bledow skladniowych, natomiast program w momencie odpalenia sie wykrzacza, a debugger jedynie wskasuje zwiazek z metoda Client::toString(), za wszelka wskazowke bede wdzieczny.