Mismatched Signatures???

Apr 4, 2016 at 1:46am
Hi,

1
2
3
4
5
6
7
8
9
10
11
class Foo
{
public:
	virtual void baz(void*) = 0;

};
class Bar : public Foo
{
public:
	void baz(Qux*); 
};


I have the feeling this isn't going to work the way I intended.
Last edited on Apr 4, 2016 at 1:47am
Apr 4, 2016 at 3:15am
https://en.wikipedia.org/wiki/Liskov_substitution_principle
Preconditions cannot be strengthened in a subtype.
Apr 4, 2016 at 3:42am
Good answer.

https://en.wikipedia.org/wiki/Precondition

In the presence of inheritance, the routines inherited by descendant classes (subclasses) do so with their preconditions in force. This means that any implementations or redefinitions of inherited routines also have to be written to comply with their inherited contract. Preconditions can be modified in redefined routines, but they may only be weakened.[2] That is, the redefined routine may lessen the obligation of the client, but not increase it.


Topic archived. No new replies allowed.