Question: Please answer in c++ Question 11. (10 marks). Pointers and Structures ou are to complete the implementation of code that represents a line in a

 Please answer in c++ Question 11. (10 marks). Pointers and Structures
ou are to complete the implementation of code that represents a line
Please answer in c++

Question 11. (10 marks). Pointers and Structures ou are to complete the implementation of code that represents a line in a two-dimensional plane. The skeleton of the code is given to you below. The code uses pointers and structs. Namely, the declarations of the two structures, struct point and struct line, are provided to you. You will need to complete the implementation of the function create line. Here are the requirements create.line takes four parameters, representing the x and y coordinates of the end point 1 and the X and Y coordinates of the end point 2. This function should dynamically allocate memory spacc to represent the line and points. You have to use struct line and struct point to represent the line and point. In create.line, you are not allowed to declare any additional variables other thanp and q. In addition, you cannot use p in the code you write, i.e., you can only use ain . At the end of createline, all of the dynamically allocated memory space has to be deleted. That is, at the end of create line, there should be no memory leak. create-line should output one line: "The 1ine is from (srex, srcy) to (dstx,dsty)." Where srcx, srcy, dstx, dsty are coordinate values of the two points. .You do not need to worry about any error handling. For example, you do not need to check that the input values are valid coordinates. An example invocation of create.line is provided in the main function. This line will cause create line to output: "The 1ine is from (2,3) to (7,8)." struct point f int *x; int *y; 2; struct 1ine f struct point *x; struct point *y; Page 17 of 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!