本文介绍了我收到错误告诉我应该使用==来分配变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我已经编写了这段代码来测试我正在编写的一些代码,只有在我使用==而不是=: #include< iostream> 使用命名空间std; int main() { int internal_organ_cream = 5; int liquid_organs = 7; & internal_organ_cream =& liquid_organs; } 我尝试像这样运行它,但它没有工作,但当我改变= = = =它工作。我不明白为什么因为我认为==当你在分配时不检查因为在这里我试图让internal_organ_cream成为liquid_organs的参考。 我尝试了什么: 没有...................... ..............................................I have written this code to test something for some code I am writing and it only works if I use == rather than =:#include <iostream>using namespace std;int main (){int internal_organ_cream = 5;int liquid_organs = 7;&internal_organ_cream = &liquid_organs;}I tried running it like this but it didnt work but when I changed the = to a == it worked. I dont understand why because i thought == was for when you are checking not when you are assigning because here i am trying to make internal_organ_cream a reference of liquid_organs.What I have tried:nothing....................................................................推荐答案这是因为&在 internal_organ_cream 前面 - 删除它们并且它将起作用:It's because of the "&" in front of internal_organ_cream - remove them both and it will work:int internal_organ_cream = 5;int liquid_organs = 7;internal_organ_cream = liquid_organs;当你输入&在变量名称前面,它返回变量的地址,而不是它的内容 - 但是当你到达指针时将会在后面解释。目前,根本就不要使用它们!When you put "&" in front of a variable name, it returns the address of the variable, rather than it's content - but that will be explained later when you get to pointers. For the moment, just don't use them at all! 这篇关于我收到错误告诉我应该使用==来分配变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-07 02:11