반응형
델파이에서 static 메소드 사용하기
C/C++ 에서는 static 변수, 함수를 지원한다.
델파이 툴로 개발을 하면서 static 함수를 본 적이 없다.
분명 있지 않을까 한느 생각에, static 메소드를 어떻게 선언하고 정의하는지 알아봤다.
선언부에서
type
TMyObject = Class
private
class function GetClassInt: integer;
class procedure SetClassInt(const Value: integer);
public
property ClassInt : integer read GetClassInt
write SetClassInt;
end;정의부분까지
unit myObjectUnit;
interface
type
TMyObject = Class
private
class function GetClassInt: integer;
class procedure SetClassInt(const Value: integer);
public
property ClassInt : integer read GetClassInt
write SetClassInt;
end;
implementation
{$WRITEABLECONST ON}
const TMyObject_ClassInt : integer = 0;
{$WRITEABLECONST OFF}
class function TMyObject.GetClassInt: integer;
begin
result := TMyObject_ClassInt;
end;
class procedure TMyObject.SetClassInt(
const Value: integer);
begin
TMyObject_ClassInt := value;
end;
end. //unit myObjectUnit메소드 선언과 정의에서 procedure 나 function 앞에 class keyword를 추가한다.
이렇게 쉽게 static 메소드를 사용할 수 있었다니...
반응형
'Delphi, RadStudio' 카테고리의 다른 글
| [개발/Delphi] TServerSocket, TClientSocket in Delphi 6 사용하기 (0) | 2013.05.06 |
|---|---|
| [개발/delphi] 엠바카데로, 멀티디바이스 네이티브 개발을 위한 RAD Studio XE4 발표 (0) | 2013.04.26 |
| [개발/델파이] MD5 - delphi에서 간단히 다루기 (0) | 2012.10.29 |
| [개발/delphi] 델파이 TChart 스크롤 기능 구현 (0) | 2012.09.23 |
| [개발/delphi] Thread 사용 예제 (0) | 2012.09.04 |
댓글