首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eclipse C++错误

Eclipse C++错误
EN

Stack Overflow用户
提问于 2012-02-18 05:17:37
回答 1查看 1.4K关注 0票数 0
代码语言:javascript
复制
/* 
 * 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);
}

错误是:

代码语言:javascript
复制
**** 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没有任何问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-18 05:53:49

因为您已经包含了<ctime>,所以将在std名称空间中定义time

因此,您需要使用完全限定的引用:std::time

这就是这个错误告诉你的:

时间错误:未在此作用域中声明‘

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9335539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档