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

Вниз

Не обязательный параметр   Найти похожие ветки 

 
kah68   (2003-06-10 12:39) [0]

Как описать функцию с необязательными параметрами (такую, например, как FreeMem(p:pointer[ ;Size:integer]))?


 
Palladin   (2003-06-10 12:41) [1]

function MyFunction(Param1:integer;Param2:integer=0);
см справку про параметры


 
Digitman   (2003-06-10 12:42) [2]

читаем хэлп :

You can specify default parameter values in a procedure or function heading. Default values are allowed only for typed const and value parameters. To provide a default value, end the parameter declaration with the = symbol followed by a constant expression that is assignment-compatible with the parameter’s type.
For example, given the declaration

procedure FillArray(A: array of Integer; Value: Integer = 0);

the following procedure calls are equivalent.

FillArray(MyArray);

FillArray(MyArray, 0);

A multiple-parameter declaration cannot specify a default value. Thus, while

function MyFunction(X: Real = 3.5; Y: Real = 3.5): Real;

is legal,

function MyFunction(X, Y: Real = 3.5): Real; // syntax error

is not.
Parameters with default values must occur at the end of the parameter list. That is, all parameters following the first declared default value must also have default values. So the following declaration is illegal.

procedure MyProcedure(I: Integer = 1; S: string); // syntax error

Default values specified in a procedural type override those specified in an actual routine. Thus, given the declarations

type TResizer = function(X: Real; Y: Real = 1.0): Real;

function Resizer(X: Real; Y: Real = 2.0): Real;
var
F: TResizer;
N: Real;

the statements

F := Resizer;

F(N);

result in the values (N, 1.0) being passed to Resizer.
Default parameters are limited to values that can be specified by a constant expression. Hence parameters of a dynamic-array, procedural, class, class-reference, or interface type can have no value other than nil as their default. Parameters of a record, variant, file, static-array, or object type cannot have default values at all.


 
kah68   (2003-06-10 12:43) [3]

Спасибо



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

Форум: "Основная";
Текущий архив: 2003.06.26;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.033 c
6-84510
mixamixa
2003-04-20 20:25
2003.06.26
Предача файлов ч/з ClientSocket & Serve


3-84015
anton_cor
2003-05-30 22:28
2003.06.26
Сделать из массива DataSource


6-84482
Денис
2003-04-22 09:32
2003.06.26
---|Ветка была без названия|---


14-84732
Rafik
2003-06-03 14:09
2003.06.26
Матрица - разочорование


6-84497
Мыш
2003-04-22 02:03
2003.06.26
вопрос по indy client-server





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский