- 作业标题: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. |
|
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. |
|
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.
|
|
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.
|
|
N/A |
Constructor | euclidean_vector(std::initializer_list<double>) |
A constructor that takes an initialiser list of double s to populate vector
magnitudes. You will have to do your own research to implement this one.
|
|
N/A |
Copy Constructor | euclidean_vector(euclidean_vector const&) |
|
N/A | |
Move Constructor | euclidean_vector(euclidean_vector&&) |
|
N/A |
2.1.1. Example Usage
auto a = comp6771::euclidean_vector(1); // a Euclidean Vector in 1 dimension, with default magnitude 0.0. |
。。。