gpt4 book ai didi

c++ - 奇怪的编译错误

转载 作者:行者123 更新时间:2023-11-30 02:06:57 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why is it an error to use an empty set of brackets to call a constructor with no arguments?

小段代码无法编译成功
微软 Visual Studio 2005

#include <iterator>
#include <algorithm>
#include <vector>
#include <iostream>

int main()
{
std::vector<int> a;
std::istream_iterator<int> be(std::cin);
std::istream_iterator<int> en();
std::copy(be, en, std::back_inserter(a));
}

但是这个还可以

#include <iterator>
#include <algorithm>
#include <vector>
#include <iostream>

int main()
{
std::vector<int> a;
std::istream_iterator<int> be(std::cin);
std::istream_iterator<int> en; //Same to upon, only here less '()'
std::copy(be, en, std::back_inserter(a));
}

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