In c++ /////////////////////////////////////////////////// point2.h ////////////////////////////////////////////////// #ifndef CSCI335_HOMEWORK1_POINTS2_H_ #define CSCI335_HOMEWORK1_POINTS2_H_ #include #include #include #include #include namespace teaching_project { // Place comments that provide a brief explanation
#ifndef CSCI335_HOMEWORK1_POINTS2_H_ #define CSCI335_HOMEWORK1_POINTS2_H_ #include #include #include #include #include namespace teaching_project { // Place comments that provide a brief explanation of the class, // and its sample usage. template class Points2 { public: // Default "big five" -- you have to alter them for your assignment. // That means that you will remove the "= default" statement. // and you will provide an implementation. // Zero-parameter constructor. // Set size to 0. Points2() = default; // Copy-constructor. Points2(const Points2 &rhs) = default; // Copy-assignment. If you have already written // the copy-constructor and the move-constructor // you can just use: // { // Points2 copy = rhs; // std::swap(*this, copy); // return *this; // } Points2& operator=(const Points2 &rhs) = default; // Move-constructor. Points2(Points2 &&rhs) = default; // Move-assignment. // Just use std::swap() for all variables. Points2& operator=(Points2 &&rhs) = default; ~Points2() = default; // End of big-five. // One parameter constructor. Points2(const std::array
#include #include #include #include using namespace std; using namespace teaching_project; // Place stand-alone function in unnamed namespace. namespace { void TestPart1() { Points2 a, b; // Two empty Points2 are created. cout a_point2{{7, 10}}; Points2 d{a_point2}; // A Points2 containing (7, 10) should be created. cout c{a}; // Calls copy constructor for c. cout e = move(c); // Move constructor for d. cout a, b; cout d = a + b; cout Question 2: 85 points For this question, you must create and test a class called Points2. This class describes a sequence of 2D points. Example 1: (1,3), (4, 5) is a sequence of two points, where each coordinate is an integer. Example 2: (1.2, 3.4), (5.6, 10.1), (11.1, 12.0) is a sequence of three points where each coordinate is a double. The sequence can be of arbitrary size and can . An empty sequence has size 0. The purpose of this assignment is to have you create a Points2 class from scratch with limited help from the STL. Since Points2 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 Weiss's "Big-Five", the destructor, copy constructor, copy assignment operator, move constructor and move assignment operator. Included are the two files (points2.h, test_points2.cc) you will need, as well as the Makefile. Do not modify the Makefile or the file names. Do not modify the test points2.cc file except by changing or adding include files if needed. You can comment in the main file the parts you didn't complete. The points2.h file is not complete. The file provides details on where to provide Included are the two files (points2.h, test_points2.cc) you will need, as well as the Makefile. Do not modify the Makefile or the file names. Do not modify the test_points2.cc file except by changing or adding include files if needed. You can comment in the main file the parts you didn't complete. The points2.h file is not complete. The file provides details on where to provide changes must be made. You are also provided with a sample input file test_input_file.txt and an explanation on how to use it is provided at the end of this document. PART 1 [55 points] Implement the "The Big-Five". Add the output stream a, b; // Two empty Points are created. cout a point2{{7, 10}}; Points2 d{a point2}; // Sequence (7, 10) should be created. cout c{a}; // Calls copy constructor for c. cout e=move(c); // Move constructor for d. cout a, b; cout d= a +b; cout *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 Weiss's "Big-Five", the destructor, copy constructor, copy assignment operator, move constructor and move assignment operator. Included are the two files (points2.h, test_points2.cc) you will need, as well as the Makefile. Do not modify the Makefile or the file names. Do not modify the test points2.cc file except by changing or adding include files if needed. You can comment in the main file the parts you didn't complete. The points2.h file is not complete. The file provides details on where to provide Included are the two files (points2.h, test_points2.cc) you will need, as well as the Makefile. Do not modify the Makefile or the file names. Do not modify the test_points2.cc file except by changing or adding include files if needed. You can comment in the main file the parts you didn't complete. The points2.h file is not complete. The file provides details on where to provide changes must be made. You are also provided with a sample input file test_input_file.txt and an explanation on how to use it is provided at the end of this document. PART 1 [55 points] Implement the "The Big-Five". Add the output stream a, b; // Two empty Points are created. cout a point2{{7, 10}}; Points2 d{a point2}; // Sequence (7, 10) should be created. cout c{a}; // Calls copy constructor for c. cout e=move(c); // Move constructor for d. cout a, b; cout d= a +b; cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance