TObject::GetHashCode - C++ Builder

C++ Builder 参考手册 ➙ System ➙ TObject ➙ GetHashCode


头文件:#include
命名空间:System
函数原型:

virtual int __fastcall GetHashCode(void);

System::TObject::GetHashCode 是 System::TObject 的成员函数,默认的返回整数值为对象的地址。

  • 默认情况,32 位程序,返回值为对象的地址;64 位程序返回值为对象的地址的高 32 位与低 32 位的异或值;

例:点击 Button1 显示 Button1 和 Form1 的 GetHashCode 值和他们的地址 (整数值)。

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    int a = Sender->GetHashCode();
    int b = (int)Sender;
    Memo1->Lines->Add(a);
    Memo1->Lines->Add(b);

    a = this->GetHashCode();
    b = (int)this;
    Memo1->Lines->Add(a);
    Memo1->Lines->Add(b);
}

运行结果:

GetHashCode 运行结果

参考:

  • System::TObject::Equals
  • System::TObject::ClassName
  • System::TObject::ClassNameIs
  • System::TObject::QualifiedClassName
  • System::TObject::UnitName
  • System::TObject::UnitScope
  • System::TObject::ClassInfo
  • System::TObject::ClassType
  • System::TObject
  • VCL 类继承关系

C++ Builder 参考手册 ➙ System ➙ TObject ➙ GetHashCode

你可能感兴趣的:(TObject::GetHashCode - C++ Builder)