Question: in c + + 1 2 . 6 6 Chapter 8 - Shoes w / Pointers In the given C + + code, there are
in c
Chapter Shoes w Pointers
In the given C code, there are three Shoes objects: shoe shoe and shoe
PrintShoesshoe will print the brands of the shoes in the linked list.
Modify the code to link the shoe shoe and shoe in a linked list.
using and do onot change the following code:
#include
#include
using namespace std;
Defining a class named "Shoes"
class Shoes
public:
string brand; Member variable to store the brand of the shoe
Shoes nextShoesAddress; Pointer to the next Shoes object in the list
;
Function to print the list of shoes
void PrintShoesShoes startShoe
Shoes currentShoe; Pointer to keep track of the current shoe
int shoeCount; Variable to keep count of the shoes
currentShoe &startShoe; Set the current shoe to the start of the list
shoeCount ;
Loop through the list of shoes until we reach the end
while currentShoe
shoeCount shoeCount ;
cout "Shoe shoeCount currentShoebrand endl;
currentShoe currentShoenextShoesAddress; Move to the next shoe in the list
return;
int main
Shoes shoe shoe shoe;
Assigning brands to each shoe
shoebrand "Nike";
shoebrand "Puma";
shoebrand "Adidas";
Code here to link shoe shoe and shoe in a linked list
Calling the function to print the list of shoes, starting from shoe
PrintShoesshoe;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
