为什么编译器期望“)”在我的函数声明中放置“,”?

时间:2012-11-14 17:54:00

标签: pascal freepascal turbo-pascal

在我的AS级计算课程中,我们使用Turbo Pascal,对于扩展工作,我已经完成了制作Blackjack / 21风格纸牌游戏的任务。我决定为普通纸牌游戏数据结构制作一个单元:

unit CardLib;

interface

type
    CardSuite = (clubs, diamonds, hearts, spades);

    Card = record
        name:String;
        value:Integer;
        suite:CardSuite;
    end;

    CardDeck = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init;
        procedure addNewCard(suite:CardSuite, name:String, value:Integer);
        procedure addCard(c:Card);
        function drawCard:Card;
        destructor done;
    end;

    CardHand = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init(deck:CardDeck, size:Integer);
        function getLowestTotal:Integer; {Aces are worth 1}
        function getHighestTotal:Integer; {Aces are worth 11}
        procedure addCard(c:Card);
        destructor done;
    end;
...

我在Turbo Pascal兼容模式下使用Free Pascal编译此代码,但是我收到以下错误:

CardLib.pas(18,39) Fatal: Syntax error, ")" expected but "," found
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

如果我注释掉addNewCard过程,我会在CardHand构造函数中得到相同的错误。是什么原因引起了这个?

1 个答案:

答案 0 :(得分:3)

使用分号分隔参数。

procedure addNewCard(suite:CardSuite; name:String; value:Integer);