相关疑难解决方法(0)

不能在数组上使用.begin()或.end()

错误如下:

请求'arr'中的成员'begin','end'是非类型int [5],无法从表达式错误中推断出来.

我的代码:

#include <iostream>
using namespace std;

int main()
{
    int * mypointer;

    int arr[5] = {1,3,5,7,9};

    mypointer = arr;

    for(auto it = arr.begin(); it != arr.end(); ++it) {
        cout<<*mypointer<<endl;

        mypointer++;
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ arrays pointers iterator c++11

25
推荐指数
2
解决办法
4万
查看次数

标签 统计

arrays ×1

c++ ×1

c++11 ×1

iterator ×1

pointers ×1