The fix is simple: Just don't have RenderTarget (which is literally named render TARGET) also be in charge of rendering things to itself.
parent
5f25383891
commit
9410d37d12
@ -0,0 +1,17 @@ |
||||
#include <iostream> |
||||
#include "constness.hpp" |
||||
|
||||
using std::cout; |
||||
|
||||
void Shape::draw(RenderTarget& target) const { |
||||
cout << "shape draw\n"; |
||||
} |
||||
|
||||
int main() { |
||||
RenderTarget target; |
||||
Shape shape; |
||||
|
||||
shape.draw(target); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,16 @@ |
||||
#pragma once |
||||
|
||||
class Drawable; |
||||
|
||||
class RenderTarget { |
||||
}; |
||||
|
||||
class Drawable { |
||||
public: |
||||
virtual void draw(RenderTarget& target) = 0; |
||||
}; |
||||
|
||||
class Shape : public Drawable { |
||||
public: |
||||
void draw(RenderTarget& target) const override; |
||||
}; |
Loading…
Reference in new issue