2013-01-15 120 views
-1

我正在写一个二十一点程序。我创建了包含两个字符串和一个整数的类卡。 'dealer'是'card'类的向量,'dtotal'和'deckplace'都是整数。 'display()'是打印卡片,套装和总数的函数。该错误发生在“else if(total> 16)”上方的行中。错误C2059:语法错误:'}'

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(); 
} 
+6

'do while' ?????????????????? – Mysticial

+1

我觉得这样做很糟糕,但-1因为没有研究,因为你的C++书没有教你'做while(X){Y}'。这意味着你做了它,并没有看到它失败时。 –

+0

我没有从书中学习C++。我不认为do循环会导致这种语法。我在发布之前研究了此语法错误的其他示例。 – user1978932

回答

11

有没有这样的事情do while。它可以是while (__condition__) { __statements__ }do { __statements__ } while (__condition__);

+0

谢谢!在讲授视觉基础之后,我混淆了! – user1978932

+0

int i(0); \t while(i ++ <5); 做; while(i ++ <10);没问题。 {}是“可选的”。 – qPCR4vir

相关问题