C++ eclipsec++;错误
除此之外,其他一切都很好。我使用minGW,它编译hello world没有问题。因为您已经包含了C++ eclipsec++;错误,c++,time,C++,Time,除此之外,其他一切都很好。我使用minGW,它编译hello world没有问题。因为您已经包含了,时间将在std命名空间中定义。 因此,您需要使用完全限定的引用:std::time 这就是这个错误告诉您的: 错误:“时间”未在此范围内声明 张贴你的实际代码。在这一点上,任何人唯一能说的就是编译器错误所说的:您引用了名为time的变量或函数,而没有首先声明它。我猜你说的是srand(time(0))而没有说#include。 /* * File: main.cpp * Author:
,时间将在std
命名空间中定义。
因此,您需要使用完全限定的引用:std::time
这就是这个错误告诉您的:
错误:“时间”未在此范围内声明
张贴你的实际代码。在这一点上,任何人唯一能说的就是编译器错误所说的:您引用了名为time
的变量或函数,而没有首先声明它。我猜你说的是srand(time(0))
而没有说#include
。
/*
* 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.