struct with an object that doesn't have default constructor

So I have a struct and inside the struct, I create an object of a class that doesn't have a default constructor. Part of the code I was given by my professor (that he said was complete) is:
1
2
3
4
struct parkedCar{
   Automobile car;
   ClaimTicket ticket;
}

and this gives error: call to implicitly-deleted default constructor of 'ParkedCar' and then the next line in console tells me that it's implicitly deleted because Automobile doesn't have a default constructor.
I got around the error and made the program work by changing Automobile car; to Automobile car(); but then I'm not sure what car is going to have as it's properties since it really doesn't have a default constructor so I'm not sure what the values would be. Is there a better way to fix this?

this is what automobile looks like:
1
2
3
4
5
6
Automobile::Automobile( const std::string & color,
                        const std::string & brand,
                        const std::string & model,
                        const std::string & plateNumber )
  : color_(color), brand_(brand), model_(model), plateNumber_(plateNumber)
{}
The compiler will create constructors for you, unless you write one or more constructors yourself.

Since Automobile has a (non-default) constructor, the only way to create one is by providing all the required arguments for the (only) constructor.

Consequently, an Automobile cannot be default constructed anywhere, including as part of other classes.

Either provide a default constructor for the Automobile, or provide a default constructor for parkedCar that correctly constructs an Automobile.

If you are not permitted to modify either one, send a polite email to your professor that says “parkedCar cannot be default constructed because Automobile cannot be default constructed. What would you like me to do to fix this?”

Hope this helps.
Topic archived. No new replies allowed.