isocpp / isocpp/CppCoreGuidelines
Can rule C.128 be applied to C.129?
Open
@franzhollerer is already working on this.
Since Sep 18, 2017.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
I have some questions about C.129 in connection with C1.128
C.129: When designing a class hierarchy, distinguish between implementation inheritance and interface inheritance
class Shape { // pure interface
public:
virtual Point center() const = 0;
virtual Color color() const = 0;
virtual void rotate(int) = 0;
virtual void move(Point p) = 0;
virtual void redraw() = 0;
// ...
};
class Impl::Shape : public Shape { // implementation
public:
// constructors, destructor
// ...
virtual Point center() const { /* ... */ }
virtual Color color() const { /* ... */ }
virtual void rotate(int) { /* ... */ }
virtual void move(Point p) { /* ... */ }
virtual void redraw() { /* ... */ }
// ...
};
Why does Impl::Shape declare the member function inherited from the base class Shape as virtual?
From C.128 I expected that they should be override.
class Impl::Circle : public Circle, public Impl::Shape { // implementation
public:
// constructors, destructor
int radius() { /* ... */ }
// ...
};
Is there a technical reason why Impl::Circle::radios() is not declared override?
Can someone please help me to figure this out.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.