Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2006.09.03;
Скачать: [xml.tar.bz2];

Вниз

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

 
Чапаев ©   (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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.037 c
2-1155120400
vodvorezlaya
2006-08-09 14:46
2006.09.03
как организовать обменн данными между приложениями


2-1155583415
RASkov
2006-08-14 23:23
2006.09.03
В классе ссылка на класс


4-1146633463
Виииктариной
2006-05-03 09:17
2006.09.03
Отсылка нажатых кнопок в другую прогу


6-1145516974
111qwe
2006-04-20 11:09
2006.09.03
Определение IP адреса подключенного клиента


2-1155646273
AlexanderMS
2006-08-15 16:51
2006.09.03
Как создать эффект нажатия левой кнопки мыши в ListBox?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский