gpt4 book ai didi

c++ - Eclipse C++ 错误

转载 作者:行者123 更新时间:2023-11-28 08:10:15 24 4
gpt4 key购买 nike

/* 
* 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);
}

错误是:

**** 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。

最佳答案

因为您包含了 <ctime> , time将在 std 中定义命名空间。
因此,您需要使用完全合格的引用:std::time .

这就是此错误告诉您的内容:

error: 'time' was not declared in this scope

关于c++ - Eclipse C++ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9335539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com