c++变态类转delphi类

xj82257695 2015-05-19 10:22:14
typedef struct _LST_DATA_ 
{
INT32U dTagSerialNumber;
TCHAR cAntennaNum[12];
TCHAR cEpcData[96];
TCHAR cTidData[64];
INT32 iTimes;
TCHAR cRSSI[8];
TCHAR cIPNUM[16];
BOOL bRealTag;


_LST_DATA_()
{
ZeroMemory(this, sizeof(*this));
}
struct Compare
{
bool operator() (_LST_DATA_ const& First, _LST_DATA_ const& Second)
{
if (wcscmp(First.cEpcData, Second.cEpcData) < 0)
{
return true;
}
return false;
}
};
struct Comparison
{
bool operator() (_LST_DATA_ const& First, _LST_DATA_ const& Second)
{
return First.dTagSerialNumber < Second.dTagSerialNumber;
}
};
}INV_DATA;

C++结构体跟类没区别,除了作用域,但跟Delphi里面结构体和类有区别,大伙帮我转成Delphi的类!
...全文
210 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
看那山瞧那水 2015-05-27
  • 打赏
  • 举报
回复
注意:结构体不支持无参数constructor Create();
  • 打赏
  • 举报
回复
TLstData=class public FTagSerialNumber: DWORD; FAntennaNum : string[12]; FEpcData: String[96]; FTidData : string[64]; FTimes: integer; FRSSI : string[8]; FIPNUM : String[16]; BOOL FRealTag:boolean; constructor Create(); function Compare(first:, Second: TLstData):boolean; function Comparison(first:, Second: TLstData):boolean; end; constructor TLstData.Create(); { FTagSerialNumber:= 0; FAntennaNum := DupeString(#0, 12); FEpcData:= DupeString(#0, 96); FTidData:= DupeString(#0, 64); FTimes:= 0; FRSSI:= DupeString(#0, 8); FIPNUM:= DupeString(#0, 16); FRealTag := False; } function TLstData.Compare(first:, Second: TLstData):boolean; begin result := CompareStr(first.FEpcData, Second.FEpcData); end; function TLstData.Comparison(first:, Second: TLstData):boolean; begin result := First.FTagSerialNumber < Second.FTagSerialNumber end; 转换成delphi的结构体更合适, d的结构体也可以包含方法,和操作符重载
xj82257695 2015-05-20
  • 打赏
  • 举报
回复
CSDN完全没落了,这里的DELPHI都没人理,一点不活跃。还是去盒子论坛更适合学习,同样的问题在那有大牛给了提示。
看那山瞧那水 2015-05-19
  • 打赏
  • 举报
回复
d7以后的结构和类也差不多了,除了以下区别: Records do not support inheritance. Records can contain variant parts; classes cannot. Records are value types, so they are copied on assignment, passed by value, and allocated on the stack unless they are declared globally or explicitly allocated using the New and Dispose function. Classes are reference types, so they are not copied on assignment, they are passed by reference, and they are allocated on the heap. Records allow operator overloading on the Win32 platform; classes, however, do not allow operator overloading. Records are constructed automatically, using a default no-argument constructor, but classes must be explicitly constructed. Because records have a default no-argument constructor, any user-defined record constructor must have one or more parameters. Record types cannot have destructors. Virtual methods (those specified with the virtual, dynamic, and message keywords) cannot be used in record types. Unlike classes, record types on the Win32 platform cannot implement interfaces.

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧