| | |
| Total Assignment Marks (Posted by Bradford Heap, Wed 4 Nov 1:23pm) |
|
Assignment Four is now marked. You can view your mark by running the command:
6771 classrun collect ass4
You can also view your total marks for all assignments with the following command:
6771 classrun sturec
Please check your marks. If there are any errors please contact the Lecturer in Charge. |
| |
| IEEE Computer Magazine: Bjarne Stroustrup - The Inventor of C++ (Posted by Bradford Heap, Sun 1 Nov 3:07pm) |
|
This is an interview with Bjarne Stroustrup that talks about some advanced aspects of C++11: https://vimeo.com/35326736
In particular the later part of the video on uniform initialisation may be of interest for exam revision. |
| |
| Revision Lecture - Monday 12pm Week 13 (Posted by Bradford Heap, Thu 22 Oct 4:08pm) |
|
Because of the Labour Day holiday the final lecture for the course will be 12pm Monday Week 13. This lecture will cover revision and the structure of the final exam. |
| |
| Assignment Three Results (Posted by Bradford Heap, Thu 22 Oct 4:07pm) |
|
To view your assignment one feedback and marks run the command:
6771 classrun collect ass3
in a terminal window on a school computer. |
| |
| Iterator Equality for Graph/Node Iterator (Posted by Bradford Heap, Thu 1 Oct 3:59pm) |
|
A few questions have been asked about the equality operator for iterators.
From: http://en.cppreference.com/w/cpp/concept/InputIterator:
"in the domain of ==" means equality comparison is defined between the two iterator values. For input iterators, equality comparison does not need to be defined for all values, and the set of the values in the domain of == may change over time.
For the node iterator on the graph there will be a test case that checks this.
The logic of the equality function should be as follows:
- If both iterator objects private data members are the same return true
- If either iterator object is at the "end" return false
- If the current dereference of the two objects are equal by value (i.e., both dereference to the same value) return true
- Return false.
|
| |
| Operator Overloading in Private Inner Classes (Posted by Bradford Heap, Tue 29 Sep 6:37pm) |
|
In addition to the notice posted below regarding the defined operators for the templated value types you may want to operator overloaded inside private classes (depending on your design and use of STL containers).
If you want a private inner class to overload an operator you need to define the friend function inline, the following code snippet gives an example.
template <typename N, typename E>
class Graph {
class PrivateInnerClass {
private:
// some private data
std::shared_ptr<N> n;
public:
// a constructor
PrivateInnerClass(std::shared_ptr<N> ptr) : n{ptr} {}
// the friend less than operator is defined inline to make the compiler happy.
friend bool operator<(const PrivateInnerClass& lhs, const PrivateInnerClass& rhs) {
return *(lhs.n) < *(rhs.n);
}
};
};
|
| |
| Assignment Three Node/Edge Templated Type Operator Functions (Posted by Bradford Heap, Tue 29 Sep 4:11pm, updated Tue 29 Sep 5:52pm) |
|
The only operator function that will always be defined for Node/Edge templated types is the operator< function.
This means that the following code may not always compile as it relies on operator==:
CustomClassObjectWithoutEqualsOperator obj("some data");
cs6771::Graph<CustomClassObjectWithoutEqualsOperator,int> g;
g.addNode(obj,1);
g.addNode(obj,1); // should return false as it is a duplicate
...
// inside the Graph definition:
// check that the node doesn't already exist.
bool checkNode(N newNode) {
for (auto currNode : nodes) {
if (currNode == newNode) {
return false; // compile time error on the line above.
// need to figure out how to do == with < operators.
// or use a different data type to store nodes.
}
}
}
|
| |
| Clarification on function mergeReplace in Assignment Three (Posted by Bradford Heap, Thu 24 Sep 5:04pm, updated Tue 29 Sep 4:21pm) |
|
Questions have been asked about the behavour of incoming nodes after the call to the function mergeReplace.
Excerpt from the specifications: The first node passed as a parameter into the function is the node destroyed after the merge. After the merge the edges of both nodes are retained, except any edges between the two nodes that are merged.
The edges referred to in this description is the edges that are outgoing from the two nodes. For incoming nodes the behaviour is different. Edges whose destination was the first parameter (e.g. the node to be destroyed) should be removed from the graph. Edges whose destination is the second parameter (e.g. the node that is retained) continue to exist in the graph.
For example, given the graph with nodes A, B, C with edges A->C and B->C After the call to mergeReplace(B,C) the remaining edge is: A->C However, after the call to mergeReplace(C,B) there are no remaining edges. |
| |
| Assignment Two Results (Posted by Bradford Heap, Wed 23 Sep 8:53am) |
|
To view your assignment one feedback and marks run the command:
6771 classrun collect ass2
in a terminal window on a school computer.
All assignments were compiled with the -fsanitize=address compiler flag to help with determining the causes of runtime memory corruption errors. You may want to use this flag when testing your assignment three and four submissions. |
| |
| Updated Assignment Three Test Case Result Files (Posted by Bradford Heap, Thu 17 Sep 9:30am) |
|
All result files for the assignment three sample test cases have been updated after a bug was found in the model solution output. |
| |
| Assignment Three Clarifications (Posted by Bradford Heap, Wed 9 Sep 8:14am) |
|
You must create at least one custom iterator class in Assignment Three. Bold text has been added to areas of the specifications to make this more clear. You should follow the example of a custom iterator that is given in week 8. |
| |
| No std::array Iterators for Assignment Two (Posted by Bradford Heap, Wed 26 Aug 4:43pm) |
|
std::array iterators in the constructors for Assignment Two will no longer be required and will not be tested for.
The dryrun has been updated to remove the tests involving std::array |
| |
| Assignment One Results (Posted by Bradford Heap, Wed 26 Aug 1:37pm, updated Thu 27 Aug 7:36pm) |
|
To view your assignment one feedback and marks run the command: 6771 classrun collect ass1 in a terminal window on a school computer. |
| |
| Common Problems in Assignment Two (Posted by Bradford Heap, Tue 25 Aug 10:41am) |
|
Below is a list of problems that people are commonly asking about and some guidance about how to solve them.
- cout is not a member of std (or similar error message) - make sure that you have #include for each library member you require in your header file (e.g., iostream).
- template functions won't compile - make sure the definition of your templated functions are in the header file (not the cpp file), template functions do not compile to .o files the same way as normal functions do.
- The constructors test case is not working for cs6771::EuclideanVector e{1,4}; (or other examples) - depending on your code you may require some additonal constructors. For instance, you may need (among others):
EuclideanVector::EuclideanVector(int d, int m) : EuclideanVector(static_cast<unsigned int>(d),static_cast<double>(m)) {} |
| |
| Assignment Two Constructors Test Case (Posted by Bradford Heap, Thu 20 Aug 9:12am, updated Wed 26 Aug 4:47pm) |
|
Below is a sample of the many ways that the EuclideanVector class constructors can be validaly called in assignment two (note: this isn't an exhaustive list either). You'll notice that sometimes an int is passed in rather than a double as the magnitude to be set, additionally there is a mixture of rvalues, lvalues and const variables. All of these should work because of implicit type conversions. There is no output produced for this test case and you should test your own code in much further detail by constructing your own test cases.
#include "EuclideanVector.h"
int main() {
cs6771::EuclideanVector a_rval{1};
unsigned int ui = 2;
cs6771::EuclideanVector a2{ui};
const int ci = 3;
cs6771::EuclideanVector a3{ci};
const unsigned int cui = 4;
cs6771::EuclideanVector a4{cui};
short unsigned si = 5;
cs6771::EuclideanVector a5{si};
std::list<int> l {1,2,4};
cs6771::EuclideanVector b{l.begin(),l.end()};
std::vector<unsigned int> v2 {4,5,6,7};
cs6771::EuclideanVector c{v2.begin(),v2.begin()+3};
std::vector<double> a1 {5,4,3.1,2,1.0};
cs6771::EuclideanVector d{a1.begin(),a1.end()};
cs6771::EuclideanVector e{1,4};
const int mag = 5;
cs6771::EuclideanVector e2{ci,mag};
cs6771::EuclideanVector e3{ui,4.9};
double d1 = 3.14;
cs6771::EuclideanVector e4{cui,d1};
}
|
| |
| Assignment Two Const Test Case (Posted by Bradford Heap, Mon 17 Aug 8:28pm) |
|
Below is a test case for helping with const correctness.
#include <iostream>
#include "EuclideanVector.h"
int main() {
std::list<double> l{1.0,2.0,3.0,4.0};
const cs6771::EuclideanVector e{ (l.begin())++, l.end()};
std::cout << e << std::endl;
std::cout << e.getNumDimensions() << std::endl;
std::cout << e.get(1) << " " << e[2] << std::endl;
std::cout << e.getEuclideanNorm() << std::endl;
std::cout << e.createUnitVector() << std::endl;
cs6771::EuclideanVector f = 6;
std::cout << std::boolalpha << (f == e) << std::endl;
f = cs6771::EuclideanVector{4,5.0} + e;
std::cout << f << std::endl;
std::cout << static_cast<std::list<double>>(e).front() << std::endl;
}
The output of this is:
[1 2 3 4]
4
2 3
5.47723
[0.182574 0.365148 0.547723 0.730297]
false
[6 7 8 9]
1
|
| |
| Assignment Two Sample Code Update (Posted by Bradford Heap, Fri 14 Aug 11:56am, updated Sun 16 Aug 9:48am) |
|
The sample test case for Assignment Two has been updated to use uniform initialisation. Please ensure your code compiles against this change. |
| |
| Assignment Two Implicit Constructor Test (Posted by Bradford Heap, Mon 10 Aug 2:29pm) |
|
The test case below using an implicit constructor should work for your assignment two submission.
#include <iostream>
#include "EuclideanVector.h"
int main() {
cs6771::EuclideanVector a = 3; // use an implicit constructor
unsigned int i = 5;
cs6771::EuclideanVector b = i;
std::cout << a << std::endl;
std::cout << b << std::endl;
}
The output should be:
[0 0 0]
[0 0 0 0 0] |
| |
| Assignment One Clarifications (Posted by Bradford Heap, Wed 29 Jul 2:59pm, updated Thu 30 Jul 9:29am) |
|
Some additional clarifications regarding assignment one:
- You will not be given test cases with nested repeat commands.
- Repeat commands will only be given if an int is at the top of the stack. Repeat commands will not be given for double.
-
No negative numbers will be given as input, however, they may be produced as output. And then used in a further calculation.
- The sqrt command should preserve the type that it was given, e.g. if it was given an int then an int should be returned.
Here is some input for these cases:
20 10 sub
5 mult
16 sqrt
16.0 sqrt
5 sqrt
5.0 sqrt
10 - 20 = -10
5 * -10 = -50
sqrt 16 = 4
sqrt 16.000 = 4.000
sqrt 5 = 2
sqrt 5.000 = 2.236
|
| |
| g++ Compiler Upgrade (Posted by Bradford Heap, Wed 29 Jul 9:13am) |
|
The g++ compiler on the school computers (used for assignment marking) has been upgraded to version 4.9.2
This upgrade should provided better support for the C++11 standard.
You should test your assignment code against this version on the school computers before the assignment submission deadline. |
| |
| Lecture Recordings (Posted by Bradford Heap, Tue 28 Jul 12:21pm) |
|
Are available from this Echo360 Portal: https://lectures.unsw.edu.au/ess/portal/section/b3397962-06dc-4b4f-9dc0-c553fbfc272b |
| |