Xref: utzoo comp.lang.c++:11913 comp.object:2623 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!dog.ee.lbl.gov!pasteur!galileo.berkeley.edu!jbuck From: jbuck@galileo.berkeley.edu (Joe Buck) Newsgroups: comp.lang.c++,comp.object Subject: Re: Static typing and OOP efficiency Message-ID: <11545@pasteur.Berkeley.EDU> Date: 28 Feb 91 23:39:25 GMT References: <1991Feb16.121825.15353@gpu.utcs.utoronto.ca> Sender: news@pasteur.Berkeley.EDU Reply-To: jbuck@galileo.berkeley.edu (Joe Buck) Lines: 24 In article , pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: |> When you write a library in C++ you tend to make everything virtual that |> can plausibly be, just in case. The people at AT&T did not make certain |> things virtual in the 'iostream' library and a lot of people are unhappy |> about that. Only people who don't understand the design. They'd be even more unhappy if the functions were virtual because they'd get function calls per character of I/O. streams and iostreams are designed to have the "streambuf" class overloaded; almost everything you can do by overloading a hypothetical iostream class with everything virtual you can do by overloading streambuf instead, and more efficiently. The important streambuf methods are virtual, and the stream classes interface to streambuf and derived classes in an efficient way. That is, iostream is the way it is to exploit both the speed of inline nonvirtual function calls and the flexibility of inheritance. It's far from perfect, but it is the way it is for good reason. -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck