Hi, i need to dynamically create and return a head node. there is only 1 and only one head node in the list. set both th

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hi, i need to dynamically create and return a head node. there is only 1 and only one head node in the list. set both th

Post by answerhappygod »

Hi, i need to dynamically create and return a head node. there
is only 1 and only one head node in the list. set both the
prev and next pointers to nullptr. u are given a previous (ie.
Car*prev )and next pointer ( ie. Car*next)in a struct named
Car. I would like to know how to create that function. My method is
to create a new node, which is called Car*head=new Car, then
head->next and head ->prev both equals to nullptr, then i
assign the data to the head, and return it. But it gives me memory
leak, pls help.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply