簡體   English   中英

在Eiffel中也得到錯誤“VEVI:變量未正確設置”

[英]Getting the error “VEVI: Variable is not properly set” in Eiffel, too

我正在嘗試為Eiffel中的linked_list“folds”創建一個代理“print_min_fold”:

------------------------ Schnipp:

class PF_HP


create
 make

feature --Queries:
--  n : NONE;

grid: separate GRID;

seq: BOOL_STRING;
strseq: STRING;
iseq: INTEGER;

zero, one: BOOLEAN;

fold: STRING;

folds: LINKED_LIST[STRING];

losses, indices: LINKED_LIST[INTEGER];
 -- indices: ARRAY[INTEGER];

i: INTEGER;
loss, min: INTEGER
 --Constructor:

make
  do

min:=9999
loss:=0

 from
  io.put_string("                           123456789012345%N")
  io.put_string ("Bitte Bitsequenz eingeben: ")
  io.read_line
 until
        (not io.last_string.is_empty) --and then io.last_string.is_bit
 loop
   io.put_string("%N")
   io.put_string("Keine Bitsequenz eingegeben. Besteht nur aus 0 und 1 in beliebiger Reihenfolge!%N")
     io.put_string("                           123456789012345%N")
     io.put_string ("Bitte Bitsequenz eingeben: ")
     io.read_line
   end
-- iseq:=io.last_integer
 strseq:=io.last_string
 create folds.make
 create losses.make
 create indices.make --from_collection(losses)
 create fold.make(strseq.count-1)
 create seq.make(strseq.count)
 --create zero.make

zero:=False
one:=True

- - - - - - - - - - - - - -等等...

 print_min_fold
do
  folds.do_all( agent print_item(?) )

end

 print_item(item: STRING)
    do
     number := number + 1
     io.put_character('#')
     io.put_integer(number)
     io.put_character(' ')
     io.put_string(item)
     io.put_character('%N')
  end -- print_item

----------------------------------- Schnapp

我得到的錯誤是:

Error code: VEVI

Error: variable is not properly set.
What to do: ensure the variable is properly set by the corresponding
setter instruction.

Class: PF_HP
Feature: print_min_fold
Creation procedure: make declared in PF_HP
Attribute(s): grid
Line: 400
do
->    folds.do_all( agent print_item(?) )

grid附加對象之前,看起來像是print_min_fold 您需要在print_min_fold之前初始化grid

或者,您可以將grid標記為detachable separate ,但是在對其進行任何調用之前,您必須使用對象測試來確保它不是無效的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM