serbod писал(а):Меня смутил "var" при объявлении поля f.
Обыкновенное объявление начала секции переменных, в данном случае полей.
Модератор: Модераторы
serbod писал(а):Меня смутил "var" при объявлении поля f.

java73 писал(а):Уже писали, что
TTest = object ?
Попробуйте как class объявить.
Type
     PVR_IVRCompositor_FnTable=^TVR_IVRCompositor_FnTable;
     TVR_IVRCompositor_FnTable=record
      SetTrackingSpace:procedure(eOrigin:TETrackingUniverseOrigin); 
        {$ifdef Windows}stdcall;{$else}cdecl;{$endif}
      GetTrackingSpace:function:TETrackingUniverseOrigin; 
      {$ifdef Windows}stdcall;{$else}cdecl;{$endif} 
     ...
    end;
procedure LoadOpenVR(const aLibName:PChar);
begin
 FreeOpenVR;
 OpenVRLibraryHandle:=LoadLibrary(aLibName);
 if OpenVRLibraryHandle=0 then begin
  raise Exception.Create(Format('Could not load library: %s',[aLibName]));
 end else begin
  @VR_InitInternal:=GetProcAddress(OpenVRLibraryHandle,'VR_InitInternal');
  @VR_ShutdownInternal:=GetProcAddress(OpenVRLibraryHandle,'VR_ShutdownInternal');
  @VR_IsHmdPresent:=GetProcAddress(OpenVRLibraryHandle,'VR_IsHmdPresent');
  @VR_GetGenericInterface:=GetProcAddress(OpenVRLibraryHandle,'VR_GetGenericInterface');
  @VR_IsRuntimeInstalled:=GetProcAddress(OpenVRLibraryHandle,'VR_IsRuntimeInstalled');
  @VR_GetVRInitErrorAsSymbol:=GetProcAddress(OpenVRLibraryHandle,'VR_GetVRInitErrorAsSymbol');
  @VR_GetVRInitErrorAsEnglishDescription:=GetProcAddress(OpenVRLibraryHandle,'VR_GetVRInitErrorAsEnglishDescription');
 end;
end;
{$APPTYPE CONSOLE}
{$IFDEF FPC}{$MODE DELPHI}{$H+}{$ENDIF}
type
  TTest = object
  const
    Epsylon = 100;
  var
    f: integer;
    class var cv1, cv2: integer;
    procedure myproc;
    class procedure testproc;
    class procedure testproc2; static;
    class procedure testproc3; static;
  end;
  procedure TTest.myproc;
  begin
    cv1 := 0;
    f := 1;
  end;
  class procedure TTest.Testproc;
  begin
    cv1 := 1;
    // f:=1;
  end;
  class procedure TTest.Testproc2;
  begin
    cv1 := 2;
    // f:=1;
  end;
  class procedure TTest.Testproc3;
  begin
    cv1 := 3;
    // f:=1;
  end;
var
  P: procedure;
begin
  P := @TTest.Myproc;
  P := @TTest.Testproc;
  P := TTest.Testproc2;
  P := TTest.Testproc3;
end.
    class procedure testproc;
    class procedure testproc2; static;
    procedure testproc3; static;       
Вернуться в Обучение Free Pascal
Сейчас этот форум просматривают: Google [Bot] и гости: 1