Re: [问题] 请推荐有稍微真实范例的物件导向书

楼主: purpose (秀才遇到肥宅兵)   2015-03-06 13:11:07
※ 引述《mself (mself)》之铭言:
: 开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
: Linux/Windows
: 问题(Question):
: 印象中,一些书说明物件导向的范例较不真实
: 极端一点,好像有看到举例
: 鸭子呱呱叫、鸽子咕咕叫,
: 鸭子和鸽子都是禽类,禽类会叫
: 禽类(鸭子).叫()是呱呱而不是咕咕
: ...
容小弟无知,岔一下题,因为说到动物的例子,突然很想贴一段话上来...
其实我个人一直认为,软件界是爱嘴泡、爱笔战的宅宅聚集地,每次看到某板又在开战,
都觉得很不意外。而这其中的佼佼者,又肯定是写 C/C++ 的最好斗。
以下摘录自:http://www.hellenico.gr/stl/drdobbs-interview.html
If you start with a base class X at the root of your hierarchy and define a
virtual equality operator on this class which takes an argument of the type
X, then derive class Y from class X. What is the interface of the equality?
It has equality which compares Y with X. Using animals as an example (OO
people love animals), define mammal and derive giraffe from mammal. Then
define a member function mate, where animal mates with animal and returns an
animal. Then you derive giraffe from animal and, of course, it has a function
mate where giraffe mates with animal and returns an animal. It's definitely
not what you want. While mating may not be very important for C++
programmers, equality is. I do not know a single algorithm where equality of
some kind is not used.
You need templates to deal with such problems. You can have template class
animal which has member function mate which takes animal and returns animal.
When you instantiate giraffe, mate will do the right thing. The template is a
more powerful mechanism in that respect.
以下摘录自:http://www.hellenico.gr/stl/drdobbs-interview.html
Q: Java is a new language, it is not a template to disable generic
programming, everything must be a class. Java how you see?
A: It took me a few months to write the program in Java. With its author
predicted the contrary, it does not arouse my interest. I did not discover
any new insights. Ever, my first time in a new language programming found no
new insights. It retains all the things I never used in C++ - inheritance,
virtual mechanism (OO garbage), and remove the useful things. It may be
successful, after all, MS DOS success, but also for your readers to learn
Java may be profitable, but it without any knowledge of the value. Look at
their implementation of the hash table, look the the sort routine use of
those "cool" the Sorting applet, and then try AWT. The best way to judge a
language is to look at its advocates to write code. "! @ # $% ^ &% $! × ¥
#", (Annotation: the original "Radix enim omnium malorum est cupiditas),
Java is obviously a money-oriented programming (MOP) example. SGI's Java
foremost advocate told me to say: "Alex, you have to go where the money is."
But I did not want to go where the money is, the kind of place, the taste is
usually good to go.
以下这篇的传闻,还需查证:
https://www.reddit.com/r/cpp/comments/2vr7q6/this_article_seems_to_suggest_virtual_destructors/coke27u
缩短版网址:http://goo.gl/uwFyid
I remember Stephanov once mentioned how in an interview they asked him why
you would make your destructors virtual. Which he responded that he never
makes his destructors virtual and his classes are used by lots of people.
作者: Killercat (杀人猫™)   2015-03-06 13:28:00
你到底多久没更新了 comp.lang.c++(以及moderated)很早就已经不是战场了 XDfreenode也是整天看不到100句话 要吵都没得吵了另外,OO people讨厌死动物了,只有写书的才爱...
楼主: purpose (秀才遇到肥宅兵)   2015-03-06 14:34:00
国外没什么在跑,是说 ptt 这边的感觉
作者: RealJack   2015-03-06 15:45:00
OO people爱动物戳到我笑点XD!
作者: carylorrk (carylorrk)   2015-03-06 17:11:00
一楼不就是猫吗 我爱死你了~~~~
楼主: purpose (秀才遇到肥宅兵)   2015-03-06 17:53:00
我也觉得那句很好笑,还有在继承、virtual 后面加个括号 OO garbage 感觉嘴泡十足,他讲话很有趣

Links booklink

Contact Us: admin [ a t ] ucptt.com