Prev
リストの前の要素へのポインタを取得します。
戻り値
例:
//— CObject::Prev() の列
#include <Object.mqh>
//—
void OnStart()
{
CObject *object_first,*object_second;
//—
object_first=new CObject;
if(object_first==NULL)
{
printf(“Object create error”);
return;
}
object_second=new CObject;
if(object_second==NULL)
{
printf(“Object create error”);
delete object_first;
return;
}
//— リンクを設定
object_first.Next(object_second);
object_second.Prev(object_first);
//— 前のオブジェクトを使用する
CObject *object=object_second.Prev();
//— オブジェクトを削除する
delete object_first;
delete object_second;
}
|
Prev
リストの前の要素へのポインタを設定します。
void Prev(
CObject* object
)
|
パラメータ
object
[in] リストの前の要素へのポインタの新しい値
例:
//— CObject::Prev(CObject*) の例
#include <Object.mqh>
//—
void OnStart()
{
CObject *object_first,*object_second;
//—
object_first=new CObject;
if(object_first==NULL)
{
printf(“Object create error”);
return;
}
object_second=new CObject;
if(object_second==NULL)
{
printf(“Object create error”);
delete object_first;
return;
}
//— リンクを設定
object_first.Next(object_second);
object_second.Prev(object_first);
//— オブジェクトを使用する
//— …
//— オブジェクトを削除する
delete object_first;
delete object_second;
}
|
Next
リストの次の要素へのポインタを取得します。
戻り値
例:
//— CObject::Next() の例
#include <Object.mqh>
//—
void OnStart()
{
CObject *object_first,*object_second;
//—
object_first=new CObject;
if(object_first==NULL)
{
printf(“Object create error”);
return;
}
object_second=new CObject;
if(object_second==NULL)
{
printf(“Object create error”);
delete object_first;
return;
}
//— リンクを設定
object_first.Next(object_second);
object_second.Prev(object_first);
//— 次のオブジェクトを使用する
CObject *object=object_first.Next();
//— オブジェクトを削除する
delete object_first;
delete object_second;
}
|
Next
リストの次の要素へのポインタを設定します。
void Next(
CObject* object
)
|
パラメータ
object
[in] リストの次の要素へのポインタの新しい値
例:
//— CObject::Next(CObject*) の例
#include <Object.mqh>
//—
void OnStart()
{
CObject *object_first,*object_second;
//—
object_first=new CObject;
if(object_first==NULL)
{
printf(“Object create error”);
return;
}
object_second=new CObject;
if(object_second==NULL)
{
printf(“Object create error”);
delete object_first;
return;
}
//— リンクを設定
object_first.Next(object_second);
object_second.Prev(object_first);
//— オブジェクトを使用する
//— …
//— オブジェクトを削除する
delete object_first;
delete object_second;
}
|
Compare
リスト内のデータ要素を他の要素と比較します。
virtual int Compare(
const CObject* node,
const int mode=0
) const
|
パラメータ
node
[in] 比較する要素へのポインタ
mode=0
[in] 比較するもの
戻り値
注意事項
例:
//— CObject::Compare(…) の例
#include <Object.mqh>
//—
void OnStart()
{
CObject *object_first,*object_second;
//—
object_first=new CObject;
if(object_first==NULL)
{
printf(“Object create error”);
return;
}
object_second=new CObject;
if(object_second==NULL)
{
printf(“Object create error”);
delete object_first;
return;
}
//— リンクを設定
object_first.Next(object_second);
object_second.Prev(object_first);
//— オブジェクトを比較する
int result=object_first.Compare(object_second);
//— オブジェクトを削除する
delete object_first;
delete object_second;
}
|
Save
データ要素をファイルに保存します。
virtual bool Save(
int file_handle
)
|
パラメータ
file_handle
[in] 既に FileOpen(…) で開かれたバイナリファイルのハンドル
戻り値
注意事項
例:
//— CObject::Save(int) の例
#include <Object.mqh>
//—
void OnStart()
{
int file_handle;
CObject *object=new CObject;
//—
if(object!=NULL)
{
printf(“Object create error”);
return;
}
//— オブジェクトデータを設定する
//— . にて。.
//— ファイルを開く
file_handle=FileOpen(“MyFile.bin”,FILE_WRITE|FILE_BIN|FILE_ANSI);
if(file_handle>=0)
{
if(!object.Save(file_handle))
{
//— ファイル保存エラー
printf(“File save: Error %d!”,GetLastError());
delete object;
FileClose(file_handle);
//—
return;
}
FileClose(file_handle);
}
delete object;
}
|
Load
データ要素をファイルから読み込みます。
virtual bool Load(
int file_handle
)
|
パラメータ
file_handle
[in] 既に FileOpen() 関数で開かれたバイナリファイルのハンドル
戻り値
注意事項
例:
//— CObject::Load(int) の例
#include <Object.mqh>
//—
void OnStart()
{
int file_handle;
CObject *object=new CObject;
//—
if(object!=NULL)
{
printf(“Object create error”);
return;
}
//— ファイルを開く
file_handle=FileOpen(“MyFile.bin”,FILE_READ|FILE_BIN|FILE_ANSI);
if(file_handle>=0)
{
if(!object.Load(file_handle))
{
//— ファイル読み込みエラー
printf(“File load: Error %d!”,GetLastError());
delete object;
FileClose(file_handle);
//—
return;
}
FileClose(file_handle);
}
//— オブジェクトを使用する
//— . にて。.
delete object;
}
|
Type
型の識別子を取得します。
戻り値
例:
//— CObject::Type() の例
#include <Object.mqh>
//—
void OnStart()
{
CObject *object=new CObject;
//—
object=new CObject;
if(object ==NULL)
{
printf(“Object create error”);
return;
}
//— オブジェクトの型を取得する
int type=object.Type();
//— オブジェクトを削除する
delete object;
}
|
Originally posted 2019-07-30 10:00:47.
0 people found this article useful
0 people found this article useful