Читаем Thinking In C++. Volume 2: Practical Programming полностью

[97] This is another example coached by Nathan Myers.

[98] For a detailed explanation of this oddity, see Items 6 and 29 in Scott Meyer’s Effective STL.

[99] We revisit multi-threading issues in Chapter 11.

[100] Chuck designed and provided the original reference implementations for bitset and also bitstring, the precursor to vector, while an active member of the C++ standards committee in the early 1990s.

[101] They will likely appear in the next revision of Standard C++.

[102] Available at http://www.sgi.com/tech/stl.

[103] As we explained earlier, the vector specialization is also a non-STL container to some degree.

[104] With Microsoft’s compilers you will have to enable RTTI; it’s disabled by default. The command-line option enable it is /GR.

[105] Compilers typically insert a pointer to a class’s RTTI table inside of its virtual function table.

[106] A dynamic_cast always gives the address of the full object—not a subobject. This will be explained more fully in the next chapter.

[107] Even more importantly, we don’t want undefined behavior. It is an error for a base class not to have a virtual destructor.

[108] The actual layout is of course implementation specific.

[109] But not detected as an error.  dynamic_cast, however can solve this problem. See the next chapter for details.

[110] Compilers can add arbitrary padding, so the size of an object must be at least as large as the sum of its parts, but can be larger.

[111] We use the term hierarchy because everyone else does, but the graph representing multiple inheritance relationships is in general a directed acyclic graph (DAG), also called a lattice, for obvious reasons.

[112] The presence of these pointers explains why the size of b is much larger than the size of four integers.  This is (part of) the cost of virtual base classes. There is also VPTR overhead due to the virtual constructor.

[113] Note that the virtual inheritance is crucial to this example. If Top were not a virtual base class, there would be multiple Top subobjects, and the ambiguity would remain. Dominance with multiple inheritance only comes into play with virtual base classes.

[114] Jerry Schwarz, the author of IOStreams, has remarked to both of us on separate occasions that if he had it to do over again, he would probably remove MI from the design of IOStreams and use multiple stream buffers and conversion operators instead.

[115] A phrase coined by Zack Urlocker.

[116] Also known as the "Gang of Four" book (GoF). Conveniently, the examples are in C++.

[117] The C++ standards states: "No translation unit shall contain more than one definition of any variable, function, class type, enumeration type or template… Every program shall contain exactly one definition of every non-inline function or object that is used in that program."

[118] This is known as Meyers’ Singleton, after its creator, Scott Meyers.

[119] Andrei Alexandrescu develops a superior, policy-based solution to implementing the Singleton pattern in Modern C++ Design.

[120] For more information, see the article "Once is Not Enough" by Hyslop and Sutter in the March 2003 issue of CUJ.

[121] For up-to-date information, visit http://hillside.net/patterns.

[122]James O. Coplien, Advanced C++ Programming Styles and Idioms, Addison-Wesley, 1992.

[123] It differs from Java in that java.util.Observable.notifyObservers( ) doesn't call clearChanged( ) until after notifying all the observers

[124] There is some similarity between inner classes and subroutine closures, which save the reference environment of a function call so it can be reproduced later.

[125]  Much of this chapter began as a translation from the Concurrency chapter in Thinking in Java, 3rd edition, Prentice Hall 2003.

[126] This is an oversimplification. Sometimes even when it seems like an atomic operation should be safe, it may not be, so you must be very careful when deciding that you can get away without synchronization. Removing synchronization is often a sign of premature optimization – things that can cause you a lot of trouble without gaining much. Or anything.

[127] This is in contrast to Java, where you must hold the lock in order to call notify() (Java’s version of signal()). Although Posix threads, on which the ZThread library is loosely based, do not require that you hold the lock in order to call signal() or broadcast(), it is often recommended.

Перейти на страницу:

Похожие книги

1С: Бухгалтерия 8 с нуля
1С: Бухгалтерия 8 с нуля

Книга содержит полное описание приемов и методов работы с программой 1С:Бухгалтерия 8. Рассматривается автоматизация всех основных участков бухгалтерии: учет наличных и безналичных денежных средств, основных средств и НМА, прихода и расхода товарно-материальных ценностей, зарплаты, производства. Описано, как вводить исходные данные, заполнять справочники и каталоги, работать с первичными документами, проводить их по учету, формировать разнообразные отчеты, выводить данные на печать, настраивать программу и использовать ее сервисные функции. Каждый урок содержит подробное описание рассматриваемой темы с детальным разбором и иллюстрированием всех этапов.Для широкого круга пользователей.

Алексей Анатольевич Гладкий

Программирование, программы, базы данных / Программное обеспечение / Бухучет и аудит / Финансы и бизнес / Книги по IT / Словари и Энциклопедии
1С: Управление торговлей 8.2
1С: Управление торговлей 8.2

Современные торговые предприятия предлагают своим клиентам широчайший ассортимент товаров, который исчисляется тысячами и десятками тысяч наименований. Причем многие позиции могут реализовываться на разных условиях: предоплата, отсрочка платежи, скидка, наценка, объем партии, и т.д. Клиенты зачастую делятся на категории – VIP-клиент, обычный клиент, постоянный клиент, мелкооптовый клиент, и т.д. Товарные позиции могут комплектоваться и разукомплектовываться, многие товары подлежат обязательной сертификации и гигиеническим исследованиям, некондиционные позиции необходимо списывать, на складах периодически должна проводиться инвентаризация, каждая компания должна иметь свою маркетинговую политику и т.д., вообщем – современное торговое предприятие представляет живой организм, находящийся в постоянном движении.Очевидно, что вся эта кипучая деятельность требует автоматизации. Для решения этой задачи существуют специальные программные средства, и в этой книге мы познакомим вам с самым популярным продуктом, предназначенным для автоматизации деятельности торгового предприятия – «1С Управление торговлей», которое реализовано на новейшей технологической платформе версии 1С 8.2.

Алексей Анатольевич Гладкий

Финансы / Программирование, программы, базы данных