I gang

Linked Lists

struct Donut {

string flavor = "Chocolate";

double price = 0.0;

Donut* next = NULL;

Donut(){}

Donut(string flavor, double price) {

this->flavor = flavor;

this->price = price;

}

void display() {

cout << flavor << "\t$" << price << endl;

}

};

void appendDonut(Donut* head, Donut* donut) - appends donut structure referenced by pointer donut to the end of the list referenced by pointer head

void displayList(Donut* head) - iterates over the list referenced by pointer head displaying each of the donuts by using the donut’s display() method

int lengthOfList(Donut* head) - iterates over the list referenced by pointer head counting how many donuts there are in the list and returns the count

Donut* findFirstDonutFlavor(Donut* head, string flavor) - iterates over the list referenced by pointer head comparing the string parameters flavor with each of the donut’s flavor member variable. If found it returns the pointer to the donut where it was found. Otherwise returns NULL

Sample Output

[0] Chocolate $0.99

[1] Boston Crm $1.99

[2] Jelly $2.99

[3] Glazed $1.99

[4] Eclair $1.99

[5] Snowy $0.99

[6] Glazed $0.99

[7] Moonraker $2.99

8 Donuts

Found Donut:

Glazed $1.99

Færdigheder: C++ Programmering

Se mere: method crm, linked it, linked int, jelly donut, endl, donuts, double linked list, declares class member variable called numberofinvoices incremented, list double linked, struct, price lists sample, linked lists linked list java, comparing lists, linked lists, list linked, simple double linked lists java, subtracting numbers linked lists, projects linked lists, create double linked lists java, recursive linked lists, doubly linked lists examples java, java double linked lists, java doubly linked lists

Om arbejdsgiveren:
( 22 bedømmelser ) Cambridge, United States

Projekt-ID: #6021995

Tildelt til:

PeinOS

Hired by the Employer

$15 USD på 1 dag
(4 bedømmelser)
1.5