2
此代碼有什麼問題?編譯器說有兩件事情,即沒有運行條目,並且運行接受不匹配條目(兩者似乎都是錯誤的),並且單獨指出在聲明之前不能使用Train(但它已被聲明)。請向我解釋發生了什麼事。Ada對象「火車」在聲明結束前不能使用
我很猶豫要顯示整個代碼,但可以這樣做。
type ItineraryType is array (0..255) of Integer;
type Train is record
Label : Integer;
Capacity : Integer;
Maxspeed : Integer;
Starts : Integer;
Itinerary : ItineraryType;
Stops : Integer;
lock : access Mutex;
end record;
task type TrainThread is
entry Run (train1:Train);
end;
task body TrainThread is
train : Train;
begin
accept Run (train1:Train) do
train := train1;
end;
end;
-- part of main
train1 := new TrainThread;
train1.Run(trains(i));
main.adb:51:05: warning: no accept for entry "Run"
main.adb:52:17: object "Train" cannot be used before end of its declaration
main.adb:54:09: no entry declaration matches accept statement
gnatmake: "main.adb" compilation error