Why specific types are rarely used as grounds for further inference

I read: "Concrete types are rarely useful as grounds for further inference" ------------ Stroustrup p. 768

How to interpret this? Does this mean that we should get a derived class from a base class with a pure virtual function? However, I see a lot of code with a derived class derived from specific types.

Can anyone help me out?

+3
source share
5 answers

, , . ? , gotchas. getchas, , , (, , , , , , , ). , , .

, , . , ? ( ) . ( , , ). , , , , , , . .

Edit:
, , - . , , , , , .

+3

, , , .

+3

", , ". , () .

+1

. , Stroustrup , , -, .. ; , , - , . OTOH, "- ... . , ". . 766

+1

The idea here is that you should not inherit types such as int, floator std::string. In any case, you will not get OO behavior from int foo(int a). Even for the int foo(std::string&)lack of virtual functions in std::stringmeans that fooit will not cause your overrides.

0
source

Source: https://habr.com/ru/post/1727549/


All Articles