错误:没有匹配的函数调用'begin(int *&)'c ++ [英] error: no matching function for call to 'begin(int*&)' c++

查看:178
本文介绍了错误:没有匹配的函数调用'begin(int *&)'c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>
#include <iterator>
using namespace std;
void print(int ia[])
{
    int *p = begin(ia);
    while(p != end(ia))
        cout<<*p++<<'\t';
}

int main()
{
    int ia[] = {1,2,3,4},i;
    print(ia);

    return 0;
}

指向ia中第一个元素的P指针。
为什么说错误:没有匹配的函数可以调用'begin(int *&)'c ++
谢谢!:)

P pointer to the first element in ia. why it said"error: no matching function for call to 'begin(int*&)' c++" thanks!:)

推荐答案

因为在 print()中,变量 ia 是指针,而不是数组。在指针上调用 begin()没有任何意义。

Because inside print(), the variable ia is a pointer, not an array. It doesn't make sense to call begin() on a pointer.

这篇关于错误:没有匹配的函数调用'begin(int *&amp;)'c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆