COMP6771 Assignment 2- Euclidean Vector


  • 作业标题:COMP9021 - Assignment 2- Euclidean Vector
  • 课程名称:University of New South Wales COMP6771 Advanced C++ Programming
  • 完成周期:6天

1. Overview

2. The Task

Write a Euclidean Vector Class Library in C++, with its interface given in include/euclidean_vector.hpp
and its implementation in source/euclidean_vector.cpp.

We have outlined all key parts of this class below that should be implemented.

2.1. Constructors

You may have to scroll horizontally to view these tables

Name Constructor Description and Hints Examples Exception: Why thrown & what message
Default Constructor euclidean_vector() A constructor that generates a euclidean vector with a dimension of 1 and magnitude of 0.0.
You can assume the integer input will always be non-negative.
(1) auto a = comp6771::euclidean_vector();
N/A
Single-argument Constructor explicit euclidean_vector(int) A constructor that takes the number of dimensions (as an int) but no magnitudes, sets the magnitude in each dimension as 0.0.
You can assume the integer input will always be non-negative.
(1) auto a = comp6771::euclidean_vector(1);
(2) int i {3};
    auto b = comp6771::euclidean_vector(i);
N/A
Constructor euclidean_vector(int, double); A constructor that takes the number of dimensions (as an int) and initialises the magnitude in each dimension as the second argument (a double). You can assume the integer input will always be non-negative.
(1) auto a = comp6771::euclidean_vector(2, 4.0);
(2) auto x = int{3};
    auto y = double{3.24};
    auto b = comp6771::euclidean_vector(x, y);
N/A
Constructor euclidean_vector(std::vector<double>::const_iterator, std::vector<double>::const_iterator) A constructor (or constructors) that takes the start and end of an iterator to a std:vector<double> and works out the required dimensions, and sets the magnitude in each dimension according to the iterated values.
std::vector<double> v;
auto b = comp6771::euclidean_vector(v.begin(),v.end());
N/A
Constructor euclidean_vector(std::initializer_list<double>) A constructor that takes an initialiser list of doubles to populate vector magnitudes. You will have to do your own research to implement this one.
auto b = comp6771::euclidean_vector{1.0, 2.0, 3.0};
N/A
Copy Constructor euclidean_vector(euclidean_vector const&)
auto a = comp6771::euclidean_vector(a);
N/A
Move Constructor euclidean_vector(euclidean_vector&&)
auto aMove = comp6771::euclidean_vector(std::move(a));
N/A

2.1.1. Example Usage

auto a = comp6771::euclidean_vector(1);      // a Euclidean Vector in 1 dimension, with default magnitude 0.0.
auto b = comp6771::euclidean_vector(2, 4.0); // a Euclidean Vector in 2 dimensions with magnitude 4.0 in both dimensions

auto v = std::vector<double>{5.0, 6.5, 7.0};
auto c = comp6771::euclidean_vector(v.begin(), v.end()); // a Euclidean Vector in 3 dimensions constructed from a vector of magnitudes

。。。


文章作者: IT神助攻
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 IT神助攻 !
  目录