mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #446 from mpark/I.25
I.25: Marked `center` and `draw` as `const`.
This commit is contained in:
commit
907b11a717
|
@ -1726,8 +1726,8 @@ You just knew that `Shape` would turn up somewhere :-)
|
||||||
|
|
||||||
class Shape { // bad: interface class loaded with data
|
class Shape { // bad: interface class loaded with data
|
||||||
public:
|
public:
|
||||||
Point center() { return c; }
|
Point center() const { return c; }
|
||||||
virtual void draw();
|
virtual void draw() const;
|
||||||
virtual void rotate(int);
|
virtual void rotate(int);
|
||||||
// ...
|
// ...
|
||||||
private:
|
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
|
class Shape { // better: Shape is a pure interface
|
||||||
public:
|
public:
|
||||||
virtual Point center() = 0; // pure virtual function
|
virtual Point center() const = 0; // pure virtual function
|
||||||
virtual void draw() = 0;
|
virtual void draw() const = 0;
|
||||||
virtual void rotate(int) = 0;
|
virtual void rotate(int) = 0;
|
||||||
// ...
|
// ...
|
||||||
// ... no data members ...
|
// ... no data members ...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user