I have 4 classes, Customer
, PickyCustomer
, SegmentCustomer
, and Delivery
.
The Delivery
class has a component within it called customer, like so:
class Delivery {
private:
Customer *customer;
Delivery(Customer *cust) // constructor
each of the Customer
classes have a method called getAcceptable()
that is overrideable and is overridden within PickyCustomer
and SegmentCustomer
From what I've read this is the correct way to call the overridden method from the Delivery
class. By keeping the customer
as a pointer it allows Delivery
to call the child methods that override the base class.
But when trying to use unique_ptr
I keep getting the error
no matching function for call to 'Delivery::Delivery(std::unique_ptr<Customer>*)'
when using the following bit of code to initialize
unique_ptr<Customer> cust1(new Customer("Name", "Home", 1000.0, 25.0, fileProduce));
shared_ptr<Delivery> cust1Delivery(new Delivery(cust1));
Can someone explain why I am getting this error, and show how I could fix this? Thanks.