COMPLEX DATA TYPE (C++) Code a struct to implement the complex data type Car: 1. Data Members Name Quantity 2. Member Functions Default Constructor Parameter Constructor 3. Non-Member Functions Print Equivalent Compare string (full name) integer (number of cars) initialize name to "noname, quantity to 0 initialize data members to specified values one parameter: car c Print data member values two parameters: car c1, car c2 return true if data members are equivalent return false if data members are not equivalent three parameters, car c1, car c2, bool less return true if less is true and c1.quantity <= c2.quantity return false is less is false and c1.enrollment > c2.enrollment I need two files i) car.h (header file) ii) car.cpp (implementation file which will rely on car.h)

icon
Related questions
Question
100%

c++ data structure

# Complex Data Type (C++)

This guide explains how to code a struct to implement the complex data type `Car`.

## 1. Data Members
- **Name**: `string` (full name)
- **Quantity**: `integer` (number of cars)

## 2. Member Functions

### Default Constructor
- Initialize `name` to "noname", `quantity` to 0.

### Parameter Constructor
- Initialize data members to specified values.

## 3. Non-Member Functions

### Print
- **Parameters**: `car c`
- **Functionality**: Print data member values.

### Equivalent
- **Parameters**: `car c1`, `car c2`
- **Functionality**: Return `true` if data members are equivalent, `false` otherwise.

### Compare
- **Parameters**: `car c1`, `car c2`, `bool less`
- **Functionality**: 
  - Return `true` if `less` is `true` and `c1.quantity <= c2.quantity`.
  - Return `false` if `less` is `false` and `c1.enrollment > c2.enrollment`.

## Files Needed
1. **car.h** (header file)
2. **car.cpp** (implementation file which will rely on car.h)
Transcribed Image Text:# Complex Data Type (C++) This guide explains how to code a struct to implement the complex data type `Car`. ## 1. Data Members - **Name**: `string` (full name) - **Quantity**: `integer` (number of cars) ## 2. Member Functions ### Default Constructor - Initialize `name` to "noname", `quantity` to 0. ### Parameter Constructor - Initialize data members to specified values. ## 3. Non-Member Functions ### Print - **Parameters**: `car c` - **Functionality**: Print data member values. ### Equivalent - **Parameters**: `car c1`, `car c2` - **Functionality**: Return `true` if data members are equivalent, `false` otherwise. ### Compare - **Parameters**: `car c1`, `car c2`, `bool less` - **Functionality**: - Return `true` if `less` is `true` and `c1.quantity <= c2.quantity`. - Return `false` if `less` is `false` and `c1.enrollment > c2.enrollment`. ## Files Needed 1. **car.h** (header file) 2. **car.cpp** (implementation file which will rely on car.h)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I am thankful to you. This looks like a complete program and very insightful. I have a question, in car.cpp file you have written
Car::Car(string name, int quantity) {
  this->name = name;
  this->quantity = quantity;
}

what does "this" mean? Can you elaborate a little? Or is there any other alternative that I can use instead of it?

Solution
Bartleby Expert
SEE SOLUTION