Re[4]: За что я не люблю С++
От: criosray  
Дата: 01.06.09 11:46
Оценка:
Здравствуйте, CreatorCray, Вы писали:

C>>Множественное наследование такой же моветон, как и goto.

CC>Какое смелое заявление.
Это факт.
http://c2.com/cgi/wiki?MisUsingMultipleInheritance
http://www.gotw.ca/publications/mill06.htm


Scott Meyers is one of the leading gurus in the C++ languages, in his book "Effective C++", the "is a" relationship for public inheritance is being mentioned in item 35: Make sure public inheritance models "is a".

Beside that, the current chairman of the ISO C++ Standard Committee, Herb Sutter, have also mentioned that in one of his articles.


We need "controlled polymorphism" LSP IS-A, but in certain code only. Public inheritance should always model IS-A as per the Liskov Substitution Principle (LSP).[3] Nonpublic inheritance can express a restricted form of IS-A, even though most people identify IS-A with public inheritance alone. Given class Derived : private Base, from the point of view of outside code, a Derived object IS-NOT-A Base, and so of course can't be used polymorphically as a Base because of the access restrictions imposed by private inheritance. However, inside Derived's own member functions and friends only, a Derived object can indeed be used polymorphically as a Base (you can supply a pointer or reference to a Derived object where a Base object is expected), because members and friends have the necessary access. If instead of private inheritance you use protected inheritance, then the IS-A relationship is additionally visible to further-derived classes, which means subclasses can also make use of the polymorphism.



C>>>А как просто вам при вызове логгера указать текущее имя файла, исходника я имею ввиду,ай как вы ругали макросы, это так, это сяк, а как вы напишете:

C>>>logger::log(__filename__, __line__, "log text")

C>>
C>>catch(Exception e) {
C>>   Log.Error(e); // через рефлексию будет собрана информация об исключении, потоке, методе, сборке, стеке вызовов(!!!)
C>>   throw;
C>>}
C>>


CC>А ничего что то, что ты написал к logger::log(__filename__, __line__, "log text") не имеет вообще никакого отношения даже близко.

Конечно имеет. Но если хотите один в один, то ради бога:
Log.Info("log text");
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.