Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help linking new node at front of list C++ Hello, I have finished most of my code, but in the main i have directions to

Help linking new node at front of list C++

Hello, I have finished most of my code, but in the main i have directions to link new node at the front of the list, set the next field of node to the beginning of the list (*list), and set the beginning of the list to node. I was wondering how to implement that? code is below

image text in transcribed

1 int main 3 Shape list; 4 read_objs (&list); 5 print objs (list) 8 void read_objs (Shape tolist) 10 I variable used to create a new node each time through the loop Shape node double x, y, z, xx, yy, zz,, rad; // temporary variables used to read in values; fill in the rest 12 13 string type, color, color21/ temporary variables used to read in values; fill in the rest 14 15 16 17 18 19 // initialize list list NULL; while (cin type) if (type. compare ("sphere") = 0) { 21 cin >x >>y > z >> rad color node new Sphere(type, color, Point(x,y,z), rad) 24 25 26 else if (type.compare ("box)0) cin >xx yy > zz > x y> z >> color color2; node new Box(type, color, color2, xx, yy, zz, Point(x,y,z)); 29 31 32 else if (type.compare ("cone"0) 35 cin >> x >> y >> z >> xx >> yy >> zz >> rad >> color >> color2; node= new Cone (type, color, color2, Point (x, y, z), Point (xx, yy, zz), rad); 39 41 42 43 // link new node at front of list: // set the next field of node to the beginning of the list (xlist) // set the beginning of the list to node

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions