ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
12 июля
411514 Топик полностью
fk0, легенда (22.05.2013 01:13 - 01:15, просмотров: 455) ответил rezident на Вы имеете в виду integer promotion под автоматическим приведением типов?
Я имею ввиду примерно такую штуку. Оно не обязательно integer. Ниже пример программы на pascal и выдаваемые компилятором ошибки. А что бы выдал C? http://en.wikipedia.org/wiki/Type_conversion#Type_promotion
program test; var i: integer; c: char; b: boolean; s: string; r: real; x: 1..10; w: word; begin x:=11; (* Warning: range check error while evaluating constants *) r:=0.5; c:=10; (* Error: Incompatible types: got "ShortInt" expected "Char" *) b:=2; (* Error: Incompatible types: got "ShortInt" expected "Boolean" *) (* Warning: range check error while evaluating constants *) c:='ab'; (* Error: Incompatible types: got "Constant String" expected "Char" *) s:='a'; c:='b'; b:=0; (* Error: Incompatible types: got "ShortInt" expected "Boolean" *) i:=1.2; (* Error: Incompatible types: got "Extended" expected "SmallInt" *) c:=i; (* Error: Incompatible types: got "Char" expected "LongInt" *) i:=c; (* Error: Incompatible types: got "Char" expected "LongInt" *) b:=i; (* Error: Incompatible types: got "Boolean" expected "LongInt" *) i:=b; (* Error: Incompatible types: got "Boolean" expected "LongInt" *) b:=c; (* Error: Incompatible types: got "Char" expected "LongWord" *) c:=b; (* Error: Incompatible types: got "Boolean" expected "LongWord" *) i:=r; r:=i; c:=r; (* Error: Incompatible types: got "Char" expected "Real" *) r:=c; (* Error: Incompatible types: got "Char" expected "Real" *) r:=b; (* Error: Incompatible types: got "Boolean" expected "Real" *) b:=r; (* Error: Incompatible types: got "Boolean" expected "Real" *) x:=i; i:=x; w:=r; (* Error: Incompatible types: got "Real" expected "Word" *) end.
[ZX]