From e1d61e465575574cb7b55c54b7e92081adcb7732 Mon Sep 17 00:00:00 2001 From: Michael Park Date: Fri, 11 Dec 2015 08:09:07 -0500 Subject: [PATCH] I.25: Marked `center` and `draw` as `const`. --- CppCoreGuidelines.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index fbbd9f5..08e3c95 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1726,8 +1726,8 @@ You just knew that `Shape` would turn up somewhere :-) class Shape { // bad: interface class loaded with data public: - Point center() { return c; } - virtual void draw(); + Point center() const { return c; } + virtual void draw() const; virtual void rotate(int); // ... private: @@ -1740,8 +1740,8 @@ This will force every derived class to compute a center -- even if that's non-tr class Shape { // better: Shape is a pure interface public: - virtual Point center() = 0; // pure virtual function - virtual void draw() = 0; + virtual Point center() const = 0; // pure virtual function + virtual void draw() const = 0; virtual void rotate(int) = 0; // ... // ... no data members ...