Error:ivalue require as left operant of assignment

解答:该错误的意思是左操作数必须为左值,这个发生错误的原因在于赋值符号的左边不能是已确定的值,如:

3=n;或3=2是错的;

如果是对函数赋值,如:

        

#include<iostream>
using namespace std;
int f1(int a[],int i){
return a[i];
}
int main(){
int a[10];
for(int i=0;i<10;i++){
a[i]=i;
cout<<a[i]<<endl;
}

f1(a,3)=6;    
for(int i=0;i<10;i++){
cout<<a[i];
}
}

本程序会发生 以上的错误 是因为函数f1()返回的是一个值而非变量等不确定的值;

解决办法:

1.将函数定义为引用类型   : int   &f1(int   a[]   ,int   i){......};  且使用引用类型之后,在赋值运算符的任何一边均可使用f1()函数;

2.使用指针类型显式调用该函数:  int * f1 (int    a[] ,  int   i){return  &a[i]  };   调用:  *f1(a,3)=6,即把a中下标为3的位置赋值为6;

        

Error:ivalue require as left operant of assignment的更多相关文章

  1. 使用bootstrap的dropdown部件时报错:error:Bootstrap dropdown require Popper.js

    前言:前端小白一枚,刚注册博客,先发个学习过程中新碰到小问题试试水吧~ 摘要:最近在学习bootstrap,偶然碰到了一个小问题,bootstrap网站也没有做过多的解释,今天分享给大家. 问题描述: ...

  2. Laravel访问出错错误信息:`Warning: require(/vendor/autoload.php): failed to open stream: No such file or dire

    错误信息:`Warning: require(/http/www.mywakavLee.cn/bootstrap/../vendor/autoload.php): failed to open str ...

  3. Uncaught Error: Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)

    引用bootstrap之后报这个错误,错误出在bootstrap.js文件中,原语句是: if(void 0===window.Tether) throw new Error("Bootst ...

  4. [Windows Phone] APP上架,遇到错误2001的解决方案。(Error:2001)

    [Windows Phone] APP上架,遇到错误2001的解决方案.(Error:2001) 问题情景 最近在开始玩Windows Phone的开发,开发的过程中虽然有点小挫折,但是参考网络许多前 ...

  5. error:no such partition grub rescue

    重新安装了ubuntu12.04后,Ubuntu开机就出现:error:no such partitiongrub rescue >一般情况下,出现这类错误是引导文件出错或者系统找不到引导文件, ...

  6. Solution for latex error:”Unknown graphics extension: .eps“ or "Can not find XXX"

    Sample code: \begin{figure*} \centering % Requires \usepackage{graphicx} \includegraphics[width=7in] ...

  7. 【转】win7与ubuntu双系统,删除ubuntu后,启动错误error:no such partition grub rescue的修复--不错

    原文网址:http://blog.sina.com.cn/s/blog_541900d50101eu9r.html win7于ubuntu双系统,进入windows后直接格式化硬盘分区将ubuntu删 ...

  8. VS EF Error: Configuration Error extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider"

    错误截图: Configuration Error :<add extension=".edmx" type="System.Data.Entity.Design. ...

  9. error:stray&#39;\243&#39;in program

    error:stray'\243'in program 问题:       C原因在编译时出现例如以下错误 error:stray'\243'in program 错误原因: 非 - 标准ascII字 ...

随机推荐

  1. vim的配置

    修改根目录下.vimrc文件: 1.设定解码,支持中文 set fileencodings=utf-8,ucs-born,gb18030,gbk,gb2312,cp936 set termencodi ...

  2. 一些琐碎的C/C++知识点

    1. C++ 数组作为函数参数 在C/C++中,当数组作为函数的参数进行传递时,数组就自动退化为同类型的指针.(在32位系统中,对任意指针求sizeof结果为4) 2. C++ 中const的用法总结 ...

  3. 团队作业4——第一次项目冲刺(Alpha版本)11.18

    a. 提供当天站立式会议照片一张 举行站立式会议,讨论项目安排: 整理各自的任务汇报: 全分享遇到的困难一起讨论: 讨论接下来的计划: b. 每个人的工作 (有work item 的ID) 1.前两天 ...

  4. python实现京东秒杀

    # _*_coding:utf-8_*_ from selenium import webdriver import datetime import time driver = webdriver.C ...

  5. django搭建web (五) views.py

    http请求: HttpRequest http响应: HttpResponse 所在位置:django.http isinstance(request,HttpResponse) True-> ...

  6. Codeforces 240 F. TorCoder

    F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...

  7. 安装Loadrunner 11.0时,弹出缺少2.8 sp1组件--解决方案(win7)

    这是因为注册表缺少FullInstallVer和Version,归根到底是madc安装的的问题 以下是解决方法: 1.运行regedit,打开注册表,进入HKEY_LOCAL_MACHINE\SOFT ...

  8. 在网络编程中的io流小问题

    在客户端和服务端调用io流进行传输数据的过程中,当将数据write到outputstream中,需要及时刷新,否则会发生io阻塞. 在输入数据的时候,最好选用BufferedReader,因为read ...

  9. JAVA_SE基础——14.循环结构语句

    建议有些基础的同学阅读,0基础可能会有些困难(最好看正文配合基础课本的例子) 所谓循环语句主要就是在满足条件的情况下反复执行某一个操作.Java提供了3种常用的循环语句,分别为for循环语句.whil ...

  10. Connect Appium Server Fail.A new session could not be created

    1.由于安卓测试机性能低下,并不能支持测试工作,想安装一个模拟器帮助测试,然后发现群里有朋友发了一个夜神模拟器..下载..安装..美滋滋的准备运行脚本.What..居然报错了..orz..然后百度查找 ...