Bartleby Related Questions 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)]
expand button
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
Check Mark
Still need help?
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
by Bartleby Expert
SEE SOLUTION
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
by Bartleby Expert
SEE SOLUTION