Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.09.03;
Скачать: CL | DM;

Вниз

Про типы/наследование   Найти похожие ветки 

 
Чапаев ©   (2006-07-21 11:53) [0]

type TMyButton=type TButton и type TMyButton=class(TButton) end;

В чём различия? Чем в дальнейшем может грозить первая форма (если никаких изменений в TButton вноситься не будет)?


 
Reindeer Moss Eater ©   (2006-07-21 11:57) [1]

В первом случае TMyButton не наследник, а просто синоним.
Во втором - полноценный наследник.


 
Чапаев ©   (2006-07-21 12:00) [2]


> В первом случае TMyButton не наследник, а просто синоним.

Синонимом был бы, если бы type TMyButton=TButton. А тут как бы новый тип... Что не наследник в терминах ООП, это понятно.


 
Мефисто   (2006-07-21 12:06) [3]

X and Y are of the same type; at runtime, there is no way to distinguish TValue from Real. This is usually of little consequence, but if your purpose in defining a new type is to utilize runtime type information--for example, to associate a property editor with properties of a particular type--the distinction between "different name" and "different type" becomes important. In this case, use the syntax

type newTypeName = type type

For example,

type TValue = type Real;

forces the compiler to create a new, distinct type called TValue.

For var parameters, types of formal and actual must be identical. For example,

type
 TMyType = type Integer
procedure p(var t:TMyType);
begin end;

procedure x;
var
 m: TMyType;
 i: Integer;
begin
 p(m); //Works
 p(i); //Error! Types of formal and actual must be identical.
end;

Note

This only applies to var parameters, not to const or by-value parameters.


 
Reindeer Moss Eater ©   (2006-07-21 12:06) [4]

В справке описано в чем  разница обеих случаев.
Для самого класа нет никаких подводных камней.
Есть разница для редактором свойств и типизированных вар-параметров.


 
Чапаев ©   (2006-07-21 12:08) [5]


> This only applies to var parameters

Во. Теперь вижу разницу. ;-)



Страницы: 1 вся ветка

Текущий архив: 2006.09.03;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.074 c
3-1150814459
wezz
2006-06-20 18:40
2006.09.03
Настройка ODBC через BDE и Источники данных (ODBC)? Одно и то же?


15-1155211149
Desdechado
2006-08-10 15:59
2006.09.03
Не пятница.... но разминка для мозгов


15-1155023387
Megabyte
2006-08-08 11:49
2006.09.03
Перевод слова из специализированной статьи


15-1155248778
Мазут Береговой
2006-08-11 02:26
2006.09.03
Вот, как идиот улыбаясь, сижу и слушаю Юмор FM...


15-1155064788
ronyn
2006-08-08 23:19
2006.09.03
Доступ к файлу