hw6+7+9: my linked list#239
Conversation
maciekgajewski
left a comment
There was a problem hiding this comment.
Nice! Few const-correctness violations and style issues.
| return Complex((mR*rhs.mR - mI*rhs.mI)/denomenator, (mI*rhs.mR - mR*rhs.mI)/denomenator); | ||
| } | ||
|
|
||
| bool operator==(const Complex& rhs) |
There was a problem hiding this comment.
This method should be const, otherwise you wold't be able to compare const objects.
| { | ||
| std::stack<Complex> tmp_stack; | ||
| Stack tmp_stack; | ||
| while(!stack.empty()) { |
There was a problem hiding this comment.
Once you implemented the iterators, you should be able to just iterate over the stack here
There was a problem hiding this comment.
@maciekgajewski please could you elaborate? std::stack doesn't expose begin and end methods
| std::size_t mSize = 0; | ||
|
|
||
| public: | ||
| typedef Complex value_type; |
There was a problem hiding this comment.
Prefer using (modern) using over obsolete typedef
|
|
||
| reference back() { | ||
| if (!mHead) | ||
| throw std::range_error("Stack is empty"); |
There was a problem hiding this comment.
This is correct, but please note: the standard library containers don't do such checks. They just require the programmer to ensure that the container is in valid state before calling certain methods.
This is a manifestation of "don't pay for what you are not using" principle.
| c.pop_back(); | ||
| assert_size(c, 0); | ||
|
|
||
| std::cout << "OK for " << typeid(T).name() << std::endl; |
There was a problem hiding this comment.
Consider using boost::typeindex to get nice, human-readable type name
| list.push_back(Complex(2, 2)); | ||
| list.push_back(Complex(3, 3)); | ||
|
|
||
| double summ = double(); |
No description provided.