【问题标题】:Error in Constructor VDM++构造函数 VDM++ 中的错误
【发布时间】:2012-12-03 14:59:45
【问题描述】:

我在 VDM++ ToolBox Academic 中遇到了一个愚蠢的错误。

当我尝试运行一个操作时,它给了我这个错误:

Run-Time Error 280: No constructor with this parameter list is in scope
value: "Game"

我的构造函数是:

public Game: Date * Team * Team ==> Game
Game(d,t1,t2) == (
    matchday := d;
    host := t1;
    visitor := t2;
    return self;
);

我在这里称它为:

game := new Game(matchday1day1,groupA.teams(2),groupA.teams(3));

我有这个声明:

public groupA : Group;
public matchday1day1 : Date;

和(分组):

public teams : seq of Team;

错误指向Game的第一个字母。

有人可以帮我吗?

【问题讨论】:

    标签: compiler-errors vdm++


    【解决方案1】:

    如果我正确阅读了您对模型的描述,那么它应该如下所示:

    class Group
    
    instance variables
    public teams : seq of Team := [new Team(),new Team(),new Team()];
    end Group
    
    class Team
    end Team
    
    class Date
    end Date
    
    class Game
    
    instance variables
    matchday: Date;
    host : Team;
    visitor : Team;
    
    operations
    public Game: Date * Team * Team ==> Game
    Game(d,t1,t2) == (
        matchday := d;
        host := t1;
        visitor := t2;
        return self;
    );
    end Game
    
    class Test
    instance variables
    
    public groupA : Group := new Group();
    public matchday1day1 : Date := new Date();
    
    operations
    
    public test : ()==>()
    test()== (
    dcl game : Game;
     game := new Game(matchday1day1,groupA.teams(2),groupA.teams(3)) ;
    )
    
    end Test
    

    我在其中添加了 Test 并初始化了变量。

    我在这里没有发现任何问题,事实上它也在Overture 中运行,这是另一个用于 VDM 的开源工具套件。我认为您的规范是正确的 VDM。在 Overture IDE 中尝试一下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-24
      • 2018-11-15
      • 2012-07-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-13
      相关资源
      最近更新 更多