|
|
@ -1,5 +1,6 @@ |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include "fix2.hpp" |
|
|
|
#include "fix2.hpp" |
|
|
|
|
|
|
|
#include <cassert> |
|
|
|
|
|
|
|
|
|
|
|
using std::cout; |
|
|
|
using std::cout; |
|
|
|
|
|
|
|
|
|
|
@ -8,19 +9,21 @@ void RenderTarget::draw(const Drawable& drawable) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Shape::draw(RenderTarget& target) const { |
|
|
|
void Shape::draw(RenderTarget& target) const { |
|
|
|
cout << "shape draw\n"; |
|
|
|
assert(false && "You should not call this, use shape.draw(target) instead."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Shape::draw(RenderTarget &target) { |
|
|
|
void Shape::draw(RenderTarget &target) { |
|
|
|
cout << "shape non-const instead\n"; |
|
|
|
cout << "shape renders without const instead\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
int main() { |
|
|
|
RenderTarget target; |
|
|
|
RenderTarget target; |
|
|
|
Shape shape; |
|
|
|
Shape shape; |
|
|
|
|
|
|
|
|
|
|
|
target.draw(shape); |
|
|
|
// uncomment this to see the error when used wrong
|
|
|
|
|
|
|
|
// target.draw(shape);
|
|
|
|
|
|
|
|
|
|
|
|
shape.draw(target); |
|
|
|
shape.draw(target); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|