DelphiÖÐʵÏÖC++/JavaÀàËƾ²Ì¬±äÁ¿µÄ¹¦ÄÜ
ÔÚÍøÉÏ¿´µ½ºÜ¶àÈ˶¼ÔÚΪDelphiÊÇ·ñÖ§³ÖC++/JavaÖеľ²Ì¬±äÁ¿¼°¾²Ì¬·½·¨µÄ¹¦ÄܶøÀ§ÈÅ,ÆäʵÕâÔÚDelphiÖÐÊǺܼòµ¥µÄ.
¾²Ì¬·½·¨¾ÍÊÇʹÓÃClass Function. ¾²Ì¬±äÁ¿ÔòʹÓõ¥Ôª¾Ö²¿±äÁ¿À´ÊµÏÖ. ´úÂëÈçÏÂ:
//=========================================
// StaticVarTestU - ¶¨ÒåÁË¿ÉÒÔ¼ÆÊýµÄÀ࣬ͨ¹ýÀà·½·¨¼´¿É·ÃÎÊ´ËÀàµÄ¶ÔÏóÊý
//=========================================
unit StaticVarTestU;
interface
type
TStaticVarClass = class
public
//constructor
constructor Create();
destructor Destroy; override;
//Àà·½·¨£¬È¡µÃ¶ÔÏóµÄ¼ÆÊý
class function ObjectCount: integer;
protected
private
end;
implementation
Var
LObjCount: integer;
{ TStaticVarClass }
constructor TStaticVarClass.Create;
begin
inc(LObjCount); //ʹÓþֲ¿±äÁ¿
end;
destructor TStaticVarClass.Destroy;
begin
dec(LObjCount); //ʹÓþֲ¿±äÁ¿
inherited;
end;
class function TStaticVarClass.ObjectCount: integer;
begin
Result := LObjCount; //·µ»Ø¾Ö²¿±äÁ¿
end;
initialization
LObjCount := 0; //³õʼ»¯
finalization
LObjCount := 0;
end.
//=========================================
// StaticTest - ²âÊÔ´úÂë,´´½¨10¸ö¶ÔÏó,²¢·ÃÎÊÆä¼ÆÊý,ÔÙFreeµô.
//=========================================
program StaticTest;
{$APPTYPE CONSOLE}
uses
SysUtils,
Classes,
StaticVarTestU in StaticVarTestU.pas;
procedure printObjCount;
begin
WriteLn(Format(The Object Count now is %d, [TStaticVarClass.ObjectCount]));
end;
var
i: integer;
mObjList: TList;
begin
{ TODO -oUser -cConsole Main : Insert code here }
mObjList := TList.Create;
printObjCount;
for i := 0 to 10 do
begin
mObjList.Add(TStaticVarClass.Create());
printObjCount;
end;
for i := 0 to mObjList.Count -1 do
begin
TStaticVarClass(mObjList.Items[i]).Free;
printObjCount;
end;
mObjList.Free;
readln;
end.
Ïà¹ØÎĵµ£º
1£®ÈçºÎѧϰ³ÌÐòÉè¼Æ£¿
JAVAÊÇÒ»ÖÖƽ̨£¬Ò²ÊÇÒ»ÖÖ³ÌÐòÉè¼ÆÓïÑÔ£¬ÈçºÎѧºÃ³ÌÐòÉè¼Æ²»½ö½öÊÊÓÃÓÚJAVA£¬¶ÔC++µÈÆäËû³ÌÐòÉè¼ÆÓïÑÔÒ²Ò»Ñù¹ÜÓá£Óбà³Ì¸ßÊÖÈÏΪ£¬ JAVAÒ²ºÃCÒ²ºÃûʲô·Ö±ð£¬ÄÃÀ´¾ÍÓá£ÎªÊ²Ã´ËûÃÇÄÜ´ïµ½Èç´Ë¾³½ç£¿ÎÒÏëÊÇÒòΪ±à³ÌÓïÑÔÖ®¼äÓй²Í¨Ö®´¦£¬Áì»áÁ˱à³ÌµÄ¾«Ë裬×ÔÈ»Äܹ»×öµ½Ò»Í¨°Ùͨ¡£ÈçºÎѧϰ³ÌÐòÉè¼ÆÀ ......
JAVA¶ÔÏóת»»ÎªXML¸ñʽ
¼òµ¥µÄ²üÊöÏÂÈçºÎ½«JAVA¶ÔÏóת»»ÎªXML¸ñʽ£¬ÏêϸÁ˽âÇë½øÈëhttp://xstream.codehaus.org/tutorial.html
JAVABEAN¶ÔÏó
userInfo.java
private String name;
& ......
public class chengfa {
public static void main(String[] args)
{
model md=new model();
md.method();
}
}
class model
{
public int count=0;
public int[]b=new int[100];
public void me ......
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
TRTRIS GAME
WRITE BY DELFAN
EMAIL : webmaster@delfan.com
URL : http://www.delfan.com
¾µä"¶íÂÞ˹·½¿é"ÓÎÏ·
×÷Õß : DELFAN
EMail : webmaster@delfan.com
Ö÷Ò³ : http://www.delfan.com
°æ±¾ÐÅÏ¢:
2002.01.13 »ù±¾Íê³É
......