2012-02-17 11 views
0
/* 
* File: main.cpp 
* Author: c1004527 
* 
* Created on February 15, 2012, 10:25 PM 
*/ 

#include <stdlib.h> 
#include <ctime> 
#include <time.h> 
#include "CardClass.h" 
#include "PlayerClass.h" 

/* 
* 
*/ 
int main(int argc, char** argv) 
{ 
    srand(time(0)); 
    CardClass deck; 
    PlayerClass player[4]; 
    deck.ShuffleCards(); 
    deck.Print(); 
    for(int i = 0; i < DECK_SIZE; i++) 
    { 
     player[i%4].AddACard(deck.DealCards()); 
    } 
    for(int i = 0; i < 4; i++) 
    { 
     player[i].SortCard(); 
    } 
    for(int i = 0; i < 4; i++) 
    { 
     cout << endl << endl 
      << "Player "<< i+1 << endl 
      << player[i]; 
    } 

    return (0); 
} 

エラーは次のとおりです。他のEclipseのC++エラー

**** Internal Builder is used for build    
**** g++ -O0 -g3 -Wall -c -fmessage-length=0 -o OLA3\OLA3\main.o ..\OLA3\OLA3\main.cpp 
..\OLA3\OLA3\main.cpp: In function 'int main(int, char**)': 
..\OLA3\OLA3\main.cpp:17:17: error: 'time' was not declared in this scope 
Build error occurred, build is stopped 
Time consumed: 114 ms. 

すべてが完全に罰金が、それをコンパイルします。私はminGWを使用し、問題なくhello worldをコンパイルします。

+3

郵便あなたの実際のコード。この時点で誰もが言うことができるのは、コンパイラのエラーが言っていることだけです。最初に宣言することなく 'time'という名前の変数や関数を参照することです。私は '#include 'とは言わずに 'srand(time(0))'と言っていると思います。 –

答えて

1

<ctime>が含まれているため、std名前空間にtimeが定義されます。
したがって、完全修飾参照:std::timeを使用する必要があります。このエラーがあなたを語っているものです

error: 'time' was not declared in this scope

+0

私は名前空間stdを使ってみました。私はまだエラーが発生します。 – todaroa