subject

Create and test a class called Points2D. This class describes a sequence of 2D points (i. e. points in the 2D-plane). For example (1, 3), (4, 5) is a sequence of two points, where each coordinate is an integer. (1.2, 3.4), (5.6, 10.1), (11.1, 12.0) is a sequence of three points where each coordinate is a double. A sequence can have any size. An empty sequence has size 0. The purpose of this assignment is to have you create a Points2D class from scratch with limited help from the STL. Since Points2D can have arbitrary size, you should use pointers. The private data members should be:
size_t size; std::array *sequence_;
Object is the template type parameter (i. e. int, double, etc.). An initial piece of code with the structure of the class is provided. Do not change the data representation (for instance do not use a vector or list to represent the sequence_).
Pay special attention to Mark Allen Weiss's "big five" in the textbook: the destructor, copy constructor, copy assignment operator, move constructor and move assignment operator.
Included are the two files (points2d. h, [login to view URL]) you will need, as well as the Makefile. Do not modify the Makefile or the file names. Do not modify the [login to view URL] file except by changing or adding include files if needed. You can comment in the main file the parts you didnā€™t complete. The points2d. h file is not complete. In the file it is explained where to provide changes. You will be provided with a sample input file [login to view URL] and it is explained at the end of this document how to use it.
This assignment will help you revisit constructors, destructors, overloading of operators, and templates. Follow a consistent C++ coding style, for instance
Implement the "big five". Add the output stream << operator.
Demonstrate that you are able to read and write data correctly by including the following code in the main file. The code is already provided for you in the main file. You can comment parts of it as you are testing your implementation. For full credit all functions should work.
void TestPart1() {
Points2D a, b; // Two empty Points2 are created.
cout << [login to view URL]() << " " << [login to view URL]() << endl; // yields 0 0.
const array a_point2d{{7, 10}};
Points2D d{a_point2d}; // Sequence (7, 10) should be created. cout << d; // Should just print (7, 10)
cout << "Enter a sequence of points (integer)" << endl; [login to view URL](); // User enters a set of points in the form:
// 3 7 4 3 2 1 10
// 3 specifies number of points. Points are the pairs // (7, 4) (3, 2) and (1, 10)
cout << "Output1: " << endl;
cout << a; // Output should be what user entered.
cout << "Enter a sequence of points (integer)" << endl; [login to view URL](); // Enter another sequence.
cout << "Output2: " << endl;
cout << b;
Points2D c{a}; // Calls copy constructor for c.
cout << "After copy constructor1 c{a}: " << endl;
cout << c;
cout << a;
a = b; // Should call the copy assignment operator for a. cout << "After assignment a = b" << endl;
cout << a;
Points2 e = move(c); // Move constructor for d. cout << "After e = move(c) " << endl;
cout << e;
cout << c;
cout << "After a = move(e) " << endl;
a = move(e); // Move assignment operator for a.
cout << a;
cout << e;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
Fast sportcars the top speeds of sportscars, given in miles per hour, are: 155 mph bmw m5 217 mph lamborghini aventador spyder 205 mph ferrari 488 205 mph nissan gtr 197 mph chevrolet corvette stingray zr1 258 mph bugatti veyron supersport 195 mph dodge viper 270 mph hennessey venom 155 mph bmw m3 195 mph mercedes sl given: topspeeds=[155; 217; 205; 205; 197; 258; 195; 270; 155; 195]; carnames=string(["bmw m5" "lamborghini aventador spyder" "ferrari 488" "nissan gtr" "chevrolet corvette stingray zr1" "bugatti veyron supersport" "dodge viper" "hennessey venom" "bmw m3" "mercedes sl"]); the variable is a rectangular array. write a function called selectcars to identify cars with the top speed within a given range, and display the identified names. the selected cars speed will be in a range given by lowerbound < speed < upperbound. inputs to the function selectcars are: a column array os all car top speeds named topspeeds, the corresponding chara
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
Least square fit to polynomial write a function leastsquarefit3pol that solves a linear system of equations to find a least squares fit of a third order polynomial to an experimental data set given as two row arrays. the function leastsquarefit3pol must explicitly solve a set of linear equations and cannot use polyfit. there should be no restriction on the size of the problem that can be solved.
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
The best definition of an idiom is a. a word or phrase that describes a noun b. a word or phrase describing a verb c. a phrase containing figurative language in which the word expresses a different idea from its exact meaning d. a phrase that compares two unlike objects or ideas
Answers: 2
You know the right answer?
Create and test a class called Points2D. This class describes a sequence of 2D points (i. e. points...
Questions
question
Mathematics, 30.08.2020 01:01
question
Biology, 30.08.2020 01:01
question
Mathematics, 30.08.2020 01:01
question
Mathematics, 30.08.2020 01:01
Questions on the website: 13722360