简体   繁体   English

错误C2059:语法错误:“}”

[英]error C2059: syntax error: '}'

I'm writing a blackjack program. 我正在写一个二十一点程序。 I created the class card which contains two strings and an integer. 我创建了包含两个字符串和一个整数的类卡。 'dealer' is a vector of class 'card', 'dtotal' and 'deckplace' are both integers. “经销商”是“卡”类的向量,“ dtotal”和“ deckplace”都是整数。 'display()' is a function that prints the cards, suits, and totals. “ display()”是一个打印卡片,西服和总计的函数。 The error occurs in the line above "else if (total>16)". 该错误发生在“否则,如果(总计> 16)”上方的行中。

void dealerTurn()
{
    if (dtotal<17)
    {
        do while (dtotal<17)
        {
            dealer.pop_back(deck[deckplace]);
            deckplace = deckplace+1;

            for (y=0;y<dealer.size();y++)
            {
                if (dealer[y].name=="A" && dtotal>21)
                {
                    dealer[y].value = 1;
                    dtotal = 0;
                    for (z=0;z<dealer.size();z++)
                        dtotal = dtotal + dealer[z].value;
                }
            }

            display();

            if (dtotal>21)
            {
                cout << endl << "-----DEALER BUSTED!-----" << endl << endl;
                dtotal = 0;
            }
        }
    }
    else if (total>16)
    {
        display();
    }
    result();
}

There is no such thing as do while . 目前是没有这样的事do while It is either while (__condition__) { __statements__ } or do { __statements__ } while (__condition__); 要么while (__condition__) { __statements__ } do { __statements__ } while (__condition__);要么while (__condition__) { __statements__ } do { __statements__ } while (__condition__); .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM