VS2008 中array怎么用?

baidu_30955319 2015-08-31 06:47:45
我在看C++ primer plus 第6版,它当中介绍:
C++11新增了模板类array,它也位于名称空间std中,
后面的编程中,有下面的代码:
#include<iostream>
#include<string>
#include<array>
const int Seasons=4;
const std::array<std::string,Seasons> snames=
{
"spring","summer","fall","winter"
};

可是编译的时候提示:
1>c:\users\showmesky\documents\visual studio 2008\projects\arrobj\arrobj\arrobj.cpp(5) : error C2039: “array”: 不是“std”的成员
我想问问,在vs2008下,array对象是怎么用的。
...全文
327 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
忘世麒麟 2015-09-01
  • 打赏
  • 举报
回复
更新一下你的vs2008.
qhh0205 2015-08-31
  • 打赏
  • 举报
回复
引用 5 楼 baidu_30955319 的回复:
[quote=引用 1 楼 qianghaohao 的回复:] 改成这样就好了。
你确定这段代码可以在VS2008 下面运行。我的还是报错。[/quote] =======================我的是VS2008====================
iyomumx 2015-08-31
  • 打赏
  • 举报
回复
VS2008不支持C++11
baidu_30955319 2015-08-31
  • 打赏
  • 举报
回复
引用 1 楼 qianghaohao 的回复:
#include <iostream>
using namespace std;

#include<string>
#include<array>
int main()
{
	const int Seasons = 4;
	const array<std::string, Seasons> snames =
	{
		"spring","summer","fall","winter"
	};
	return 0;
}
改成这样就好了。
你确定这段代码可以在VS2008 下面运行。我的还是报错。
qhh0205 2015-08-31
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include <iostream>
using namespace std;

#include<string>
#include<array>
int main()
{
	const int Seasons = 4;
	const std::array<std::string, Seasons> snames =
	{
		"spring","summer","fall","winter"
	};
	return 0;
}
这样也对着呀。
qhh0205 2015-08-31
  • 打赏
  • 举报
回复
#include <iostream>
using namespace std;

#include<string>
#include<array>
int main()
{
	const int Seasons = 4;
	const array<std::string, Seasons> snames =
	{
		"spring","summer","fall","winter"
	};
	return 0;
}
改成这样就好了。
nanjun520 2015-08-31
  • 打赏
  • 举报
回复
08不支持11
以下 copy 于 百度百科

Visual Studio 2008

2007年11月6日从国外媒体处获悉:日前在西班牙巴塞罗那举行的TechED 2007大会上,微软公司高层表示,将会在月底发布Visual Studio 2008和3.5版本的.NET框架。

C++11标准由国际标准化组织(ISO)和国际电工委员会(IEC)旗下的C++标准委员会(ISO/IEC JTC1/SC22/WG21)于2011年8月12日公布[2] ,并于2011年9月出版。2012年2月28日的国际标准草案(N3376)是最接近于C++11标准的草案(仅编辑上的修正)。此次标准为C++98发布后13年来第一次重大修正。

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧