Deutsch
Germany.ruФорумы → Архив Досок→ Программирование

базовая литература по программированию

1635  1 2 3 4 5 6 7 8 9 10 все
barma_lej старожил01.09.06 12:18
barma_lej
NEW 01.09.06 12:18 
в ответ Tomasson 01.09.06 11:07
Вот здесь, достаточно хорошо про OOP в PHP. http://www.bhv.ru/books/book.php?id=6643
Это про PHP4 http://www.zipsites.ru/books/php4/
Это сайт Котерова (автора) http://www.dklab.ru/
Ч╦ воды столько налили? Книги где?
#41 
voxel3d коренной житель01.09.06 12:38
voxel3d
NEW 01.09.06 12:38 
в ответ barma_lej 01.09.06 12:18
> Ч╦ воды столько налили? Книги где?
A срифмуй.
Dropbox - средство синхронизации и бэкапа файлов.
#42 
Murr коренной житель01.09.06 15:33
Murr
NEW 01.09.06 15:33 
в ответ Tomasson 01.09.06 11:07
та сможет, конечно.
-------
Т.е. Утверждается, что _программировать_ - составлять алгоритмы обработки данных и записывать их на каком-то языке _уже_ умеет. Зачем ему базовая литература?
Кстати, так как быть с PHP-никами, которые хотят освоить ООП?
------
Переучить на VB 6.0... и тихонечко перестрелять... Если чуть серьезнее - сегодня полдня убил на то, чтобы объяснить, как раскидать заданный XML-документ на классы... в соответствии с ООП. Мне все время кивали на босовский код... в котором я попутно правлю баги и добавляю фичи... который не-совсем-ООП... хммм... если говорить правду - совсем не ООП... Так что - переучивать и расстереливать...
#43 
  scorpi_ скептик03.09.06 04:05
03.09.06 04:05 
в ответ Tomasson 01.09.06 09:35
Ок, давайте лит-ру по любому языку. Пусть даже по этому ужасному С++ :-)
Только такую, чтобы не отбить у человека желание обучаться :-)

С++ для начинающих только Кёниг - http://www.amazon.de/Intensivkurs-Schneller-Einstieg-%fcber-Standardbibliothek/d...
#44 
igna завсегдатай03.09.06 10:25
NEW 03.09.06 10:25 
в ответ scorpi_ 31.08.06 10:29
В ответ на:
template<class T> inline
const T& max( const T& left, const T& right )
{
return left < right ? right : left;
}
Я думаю это действительно несложно.

max(1, 1.1) // Так можно?
#45 
voxel3d коренной житель03.09.06 12:51
voxel3d
NEW 03.09.06 12:51 
в ответ igna 03.09.06 10:25
Нет, надо одинаковые типы указывать, автоматически здесь типы не будут приведены. Кроме того автоматическое приведение типов здесь было бы вредным, из-за возможного "обрезания" значения.
Dropbox - средство синхронизации и бэкапа файлов.
#46 
igna завсегдатай03.09.06 13:42
NEW 03.09.06 13:42 
в ответ voxel3d 03.09.06 12:51
Хотел спросить у scorpi_, как несложно определить max таким образом, чтобы max(a, b) работало как (a < b ? b : a) также для случая когда a - int, а b - double.
#47 
  scorpi_ скептик03.09.06 13:44
NEW 03.09.06 13:44 
в ответ igna 03.09.06 13:42
А компилятор читающий Ваши мысли, Вам случайно не нужен?
#48 
  scorpi_ скептик03.09.06 17:24
NEW 03.09.06 17:24 
в ответ voxel3d 01.09.06 10:19
Как раз в тему свежая статья от Спольского: http://www.joelonsoftware.com/items/2006/09/01.html
#49 
igna завсегдатай03.09.06 23:38
NEW 03.09.06 23:38 
в ответ scorpi_ 03.09.06 13:44
Будет ли считаться читающим мысли компилятор способный откомпилировать следующее:
template<class T1, class T2> inline
const auto& max( const T1& left, const T2& right )
{
return left < right ? right : left;
}

#50 
voxel3d коренной житель03.09.06 23:41
voxel3d
NEW 03.09.06 23:41 
в ответ igna 03.09.06 23:38, Последний раз изменено 03.09.06 23:42 (voxel3d)
Нет, не будет, поэтому, то, что Вы привели, будет работать неправильно.
Dropbox - средство синхронизации и бэкапа файлов.
#51 
  scorpi_ скептик03.09.06 23:43
NEW 03.09.06 23:43 
в ответ igna 03.09.06 23:38
Видите ли, этот код в данном случае можно откомпилировать двумя способами - либо сравнивая double c double, либо int c int. Вам какой из? Откуда должен компилятор знать, какой вариант Вас интересует?
#52 
igna завсегдатай03.09.06 23:47
NEW 03.09.06 23:47 
в ответ scorpi_ 03.09.06 23:43
В ответ на:
Откуда должен компилятор знать, какой вариант Вас интересует?

Оттуда же, откуда он знает в случае выражения left < right ? right : left. 5.16 стандарта C++.
#53 
igna завсегдатай03.09.06 23:55
NEW 03.09.06 23:55 
в ответ voxel3d 03.09.06 23:41
В ответ на:
Нет, не будет, поэтому, то, что Вы привели, будет работать неправильно.

Внести такое использование слова auto в стандарт предложили Bjarne Stroustrup и Jaakko Järvi:
http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1607.pdf#search=%22N1607%22 5.2 Functions with implicit return types
То есть это не совсем фантастика вроде чтения мыслей компиляторами.
#54 
voxel3d коренной житель04.09.06 00:12
voxel3d
NEW 04.09.06 00:12 
в ответ igna 03.09.06 23:55, Последний раз изменено 04.09.06 00:15 (voxel3d)
Ну, и? Тип возвращаемого значения функции предлагается выводить по типу того, что попадает в оперетор return. Внутри функции, один хрен, будет происходить:
тип_левого_операнда.operator<((тип_левого_операнда)правый_операнд), (я про пример Ваш)
поэтому, работать оно будет неправильно.
Dropbox - средство синхронизации и бэкапа файлов.
#55 
igna завсегдатай04.09.06 00:22
NEW 04.09.06 00:22 
в ответ voxel3d 04.09.06 00:12
В ответ на:
тип_левого_операнда.operator<((тип_левого_операнда)правый_операнд)

Нет, не так. Определение типа выражения (left < right ? right : left) описано в 5.16 стандарта C++. Там это занимает целую страницу или около того. Дать цитату?
#56 
voxel3d коренной житель04.09.06 00:27
voxel3d
NEW 04.09.06 00:27 
в ответ igna 04.09.06 00:22
> Дать цитату?
Да, киньте, pls, у меня нет под рукой, а выкачивать модемом, не до этого сейчас.
Dropbox - средство синхронизации и бэкапа файлов.
#57 
igna завсегдатай04.09.06 00:32
NEW 04.09.06 00:32 
в ответ voxel3d 04.09.06 00:27
5.16 Conditional operator [expr.cond]
conditional-expression:
logical-or-expression
logical-or-expression ? expression : assignment-expression
1 Conditional expressions group right-to-left. The first expression is implicitly converted to bool (clause 4).
It is evaluated and if it is true, the result of the conditional expression is the value of the second expression,
otherwise that of the third expression. All side effects of the first expression except for destruction of
temporaries (12.2) happen before the second or third expression is evaluated. Only one of the second and
third expressions is evaluated.
2 If either the second or the third operand has type (possibly cv-qualified) void, then the lvalue-to-rvalue
(4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the second
and third operands, and one of the following shall hold:
- The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type of
the other and is an rvalue.
- Both the second and the third operands have type void; the result is of type void and is an rvalue.
[Note: this includes the case where both operands are throw-expressions. ]
3 Otherwise, if the second and third operand have different types, and either has (possibly cv-qualified) class
type, an attempt is made to convert each of those operands to the type of the other. The process for determining
whether an operand expression E1 of type T1 can be converted to match an operand expression E2
of type T2 is defined as follows:
- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be implicitly converted (clause 4) to the
type ⌠reference to T2■, subject to the constraint that in the conversion the reference must bind directly
(8.5.3) to E1.
- If E2 is an rvalue, or if the conversion above cannot be done:
- if E1 and E2 have class type, and the underlying class types are the same or one is a base class of
the other: E1 can be converted to match E2 if the class of T2 is the same type as, or a base class of,
the class of T1, and the cv-qualification of T2 is the same cv-qualification as, or a greater cvqualification
than, the cv-qualification of T1. If the conversion is applied, E1 is changed to an
rvalue of type T2 that still refers to the original source class object (or the appropriate subobject
thereof). [Note: that is, no copy is made. ]
- Otherwise (i.e., if E1 or E2 has a nonclass type, or if they both have class types but the underlying
classes are not either the same or one a base class of the other): E1 can be converted to match E2 if
E1 can be implicitly converted to the type that expression E2 would have if E2 were converted to an
rvalue (or the type it has, if E2 is an rvalue).
Using this process, it is determined whether the second operand can be converted to match the third
operand, and whether the third operand can be converted to match the second operand. If both can be converted,
or one can be converted but the conversion is ambiguous, the program is ill-formed. If neither can
be converted, the operands are left unchanged and further checking is performed as described below. If
exactly one conversion is possible, that conversion is applied to the chosen operand and the converted
operand is used in place of the original operand for the remainder of this section.
4 If the second and third operands are lvalues and have the same type, the result is of that type and is an
lvalue.
5 Otherwise, the result is an rvalue. If the second and third operand do not have the same type, and either has
(possibly cv-qualified) class type, overload resolution is used to determine the conversions (if any) to be
applied to the operands (13.3.1.2, 13.6). If the overload resolution fails, the program is ill-formed. Otherwise,
the conversions thus determined are applied, and the converted operands are used in place of the original
operands for the remainder of this section.
6 Lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed
on the second and third operands. After those conversions, one of the following shall hold:
- The second and third operands have the same type; the result is of that type.
- The second and third operands have arithmetic or enumeration type; the usual arithmetic conversions
are performed to bring them to a common type, and the result is of that type.
- The second and third operands have pointer type, or one has pointer type and the other is a null pointer
constant; pointer conversions (4.10) and qualification conversions (4.4) are performed to bring them to
their composite pointer type (5.9). The result is of the composite pointer type.
- The second and third operands have pointer to member type, or one has pointer to member type and the
other is a null pointer constant; pointer to member conversions (4.11) and qualification conversions
(4.4) are performed to bring them to a common type, whose cv-qualification shall match the cvqualification
of either the second or the third operand. The result is of the common type.
#58 
  scorpi_ скептик04.09.06 00:42
NEW 04.09.06 00:42 
в ответ igna 04.09.06 00:32, Последний раз изменено 04.09.06 00:52 (scorpi_)
Зачем столько цитировать? Там нас интересует только
В ответ на:
After those conversions, one of the following shall hold:
- The second and third operands have the same type; the result is of that type.
- The second and third operands have arithmetic or enumeration type; the usual arithmetic conversions are performed to bring them to a common type, and the result is of that type.

Что отсылает нас к 5(9):
В ответ на:
Many binary operators that expect operands of arithmetic or enumeration type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result.
This pattern is called the usual arithmetic conversions, which are defined as follows:
- If either operand is of type long double, the other shall be converted to long double.
- Otherwise, if either operand is double, the other shall be converted to double.
...

Во-вторых, при чём тут всё это?
#59 
voxel3d коренной житель04.09.06 00:57
voxel3d
NEW 04.09.06 00:57 
в ответ scorpi_ 04.09.06 00:42, Последний раз изменено 04.09.06 00:59 (voxel3d)
Угу, только ещё надо добавить, что в операторе ?: вычисляется первое выражение и его тип приводится к bool. Всё остальное описание в 5.16 - о правилах выведения типа конечного результата и к процессу вычисления первого логического выражения отношения не имеет.
Dropbox - средство синхронизации и бэкапа файлов.
#60 
1 2 3 4 5 6 7 8 9 10 все