Look at the following code:
structure Rectangle
{
int length;
int width;
};
Rectangle *r = nullptr
Write statements that
A) dynamically allocate a Rectangle structure variable and user to point to it.
B) assign 10 to the structure’s length member and 14 to the structure’s width member.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Mylab Programming With Pearson Etext -- Access Card -- For Starting Out With C++: From Control Structures Through Objects, Brief Version
Additional Engineering Textbook Solutions
Introduction to Programming Using Visual Basic (10th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Experiencing MIS
C How to Program (8th Edition)
- When constructing an instance of a structure, what kind of effects does using the new operator have?arrow_forwardC++ OOP PART 1: A phone number, such as (212) 767-8900, can be thought of as having three parts: the area code(212), the exchange (767), and the number (8900). Write a program that uses a structure to store thesethree parts of a phone number separately. Call the structure phone. Create two structure variables of typephone. Initialize one, and have the user input a number for the other one. Then display both numbers.The interchange might look like this: Enter your area code, exchange, and number: 415 555 1212 My number is (212) 767-8900 Your number is (415) 555-1212PART 2: Differentiate between deep and shallow copy with suitable code.arrow_forwardWhy should you use the new operator to generate instances of a structure?arrow_forward
- What effect does the new operator have when creating an instance of a structure?arrow_forwardA member of a structure or of a class is accessed using : c++ A. Comma operator B. The dot operator C. The indexing operator D. The ampersand operatorarrow_forwardC code blocks nly write the missing structure definition which is required to complete the program below. The program determines the distance between two 3D points. The structure should have three members: X, Y and Z of type float. // Your answer starts here// Your answer ends herefloat distance(point n1, point n2);int main(){point n1, n2;float temp;scanf("%f %f %f", &n1.X, &n1.Y, &n1.Z);scanf("%f %f %f", &n2.X, &n2.Y, &n1.Z);temp = distance(n1, n2);printf("Distance = %.1f", temp);return 0;}float distance(point n1, point n2){float temp;temp = sqrt(pow(n1.X-n2.X,2)+pow(n1.Y-n2.Y,2)+pow(n1.Z-n2.Z,2)); return temp;} For example: Input Result 2.3 4.5 2.5 3.4 5 9.8 Distance = 9.9arrow_forward
- need code in C++ answer all parts Assume the Product structure is declared as follows: struct Product{string description; // Product descriptionint partNum; // Part numberdouble cost; // Product cost};1. Add two constructors to the Product structure declaration. The firstshould be a default constructor that sets the description member to the null string and the partNum and cost members to zero. The second con-structor should have three parameters: a string, an int, and a double. It should copy the values of the arguments into the description, partNum,and cost members.2. Define a print function as member of the struct that prints an object ofthis struct in the following format.Description: Claw Hammer PartNumber: 547Part Cost: $8.293. Declare an array of size 5 with pointers and named it ”items”. Initilize itwith user input values.4. Write a print function (not as a member of the struct) and pass a pointerto the pointer that points to the array(double pointer) and print all theitems of…arrow_forwardOnce you have created an instance of a structure, how can you access its fields?arrow_forwardTrue or FalseThe fields contained in a structure must be of the same data type.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr