VC++与Dephi的区别
来源:互联网 发布:淘宝网注册网店步骤 编辑:程序博客网 时间:2024/04/30 20:30
unit
interface
uses
;The component used by the unit Example:ActiveX
{在这里加入的unit,在之后的代码中就可以直接使用它的成员,不需要unit加.限定成员位置,和VC的using很相像}
type
TypeName = class(BaseTypeName)
procedure functionName(param : Type)
private
{ Private declarations }
public
{ public declarations }
end
implementation
{$R*.dfm}
;The message handle function is the the class member function
procedure ClassName.FunctionName(param1:type...)
var
begin
end
var
;global member
{the class use the = operation to assign classnamea = classnameb}
{struct is the "packed record"}
{the referrence operation is ^ "^member"}
initialization
finalization
end
{Dephi 比VC++ 有了更多的封装,没有提供事件的机制,而提供了相应的方法来处理事件,很可能是语言提供了用来分配事件处理函数的关键字,这样达到了一定的对WINDOWS事件机制的封装效果}
{使用了非常简单的统一的方式来实现继承,类别名,就是=操作符}
{定义了一些特殊的关键字来实现结构体,packed record}
Delphi 使用了property 来实现属性功能 使用[Index: Integer] 来支持属性数组,Index是关键字。
枚举型数组:
TIdStatus = ( hsResolving,
hsConnecting,
hsConnected,
hsDisconnecting,
hsDisconnected,
hsStatusText,
ftpTransfer, // These are to eliminate the TIdFTPStatus and the
ftpReady, // coresponding event
ftpAborted); // These can be use din the other protocols to.
const
IdStati: array[TIdStatus] of string = (
RSStatusResolving,
RSStatusConnecting,
RSStatusConnected,
RSStatusDisconnecting,
RSStatusDisconnected,
RSStatusText,
RSStatusText,
RSStatusText,
RSStatusText);
这里就使用了TIdStatus来做为数组的索引.
非常有趣的Dephi异常处理:
raise object at address
这里的object是指一个从SysUnit.Exception类或其子类的实例.
而这里的address表示的是你所想指定引发异常的地址.
这个地址常常是堆栈中之前的函数地址,它其实才是真正引发异常的位置.
这个地址可以通过内连汇编来得到:
class procedure TList.Error(const Msg: string; Data: Integer);
function ReturnAddr: Pointer;
asm
MOV EAX,[EBP+4] //对,只要使用EBP寄存器就可以了
end;
begin
raise EListError.CreateFmt(Msg, [Data]) at ReturnAddr;
end;
但是这种功能是C++所不具有的,而且其它的语言一般也不具备.
Delphi语言没有new关键字,它是直接使用构造函数Create来生成一个新的对象.
C++中的catch使用except on来表示
待续...
- VC++与Dephi的区别
- Dephi 的接口与回调 :ZT
- Dephi的过程与函数第一次使用
- VB与VC的区别
- VC与PE的区别
- QT与VC的区别
- Vb 与 Vc 的区别
- VS与VC的区别
- Vs2010与VC的区别
- dephi 随机数的产生
- dephi窗体的释放
- VC之sendmessage与postmessage的区别
- 【vc】CPaintDC, CClientDC与CWindowDC的区别
- vc中bool与BOOL的区别
- VC之sendmessage与postmessage的区别
- [VC/C++]debug与release的区别
- vc中的debug与release的区别
- VC之sendmessage与postmessage的区别
- 我的读书生涯
- .net中SqlConnection中连接字符串 ConnectionString 中的关键字值的有效名称
- Photoshop图层混合模式计算公式大全
- 15种导致失败的性格
- 如何在ACCESS数据库中批量替换内容
- VC++与Dephi的区别
- HTML系列之二-元素
- CXO解释
- linux编译器 GCC 4.3.0已经发布
- HTML系列之三-基本标签
- 效用计算
- Return multiple dataset
- 让实践,而不是条文说话
- 学习《TCP/IP详解卷1:协议》- TCP