| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:nullptr编译错误
只看楼主 加入收藏
wiseley747
Rank: 1
等 级:新手上路
帖 子:22
专家分:8
注 册:2012-8-16
结帖率:100%
收藏
 问题点数:0 回复次数:1 
nullptr编译错误
初学visual c++2008  拿个范例测试 但无法编译成功 不知哪里有错
程序代码:
#include < iostream >
#include < iomanip >
using std::cin;
using std::cout;
using std::endl;
using std::setw;

int main()
{
long* pprime(nullptr);
long trial(5); // Candidate prime
int count(3); // Count of primes found
int found(0); // Indicates when a prime is found
int max(0); // Number of primes required
cout << endl
<< "Enter the number of primes you would like (at least 4): ";
cin >> max; // Number of primes required
if(max < 4) // Test the user input, if less than 4
max = 4; // ensure it is at least 4
pprime = new long[max];
*pprime = 2; // Insert three
*(pprime + 1) = 3; // seed primes
*(pprime + 2) = 5;
do
{
trial += 2; // Next value for checking
found = 0; // Set found indicator
for(int i = 0; i < count; i++) // Division by existing primes
{
found =(trial % *(pprime + i)) == 0;// True for exact division
if(found) // If division is exact
break; // it's not a prime
}
if (found == 0) // We got one...
*(pprime + count++) = trial; // ...so save it in primes array
} while(count < max);
// Output primes 5 to a line
for(int i = 0; i < max; i++)
{
if(i % 5 == 0) // New line on 1st, and every 5th line
cout << endl;
cout << setw(10) << *(pprime + i);
}
delete [] pprime; // Free up memory
pprime = nullptr; // and reset the pointer
cout << endl;
return 0;
}
搜索更多相关主题的帖子: 成功 visual 测试 
2012-10-09 11:19
wiseley747
Rank: 1
等 级:新手上路
帖 子:22
专家分:8
注 册:2012-8-16
收藏
得分:0 
回复 楼主 wiseley747
找到原因了 編譯換成VS2010即可
VS2008不支援這樣寫法
2012-10-09 16:00
快速回复:nullptr编译错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034155 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved