简体   繁体   English

错误:语句无法解析重载函数C ++的地址

[英]error: statement cannot resolve address of overloaded function C++

I am studying C++ by book and was trying to test simple coding for a looped game combat. 我正在按书学习C ++,并试图测试循环游戏中的简单编码。 A switch inside a while loop. while循环内的一个开关。

damage = greatsword[0] + player[1] - enemy[2]; endl;

error: statement cannot resolve address of overloaded function| 错误:语句无法解析重载函数的地址|

I have this error in 4 different code lines and in each one it has 'damage' so I assume its some problem with that. 我在4个不同的代码行中都有此错误,并且每行都有“损坏”,因此我认为这是有问题的。 I have damage declared as an int and set to 0 before trying to change it to the attack value. 在尝试将其更改为攻击值之前,我已将伤害声明为int并设置为0。 I can provide more of the code if needed. 如果需要,我可以提供更多代码。 I also tried changing the name from x to dmg to see if that was the problem 我还尝试将名称从x更改为dmg,以查看是否是问题所在

You have a trailing endl; 你有尾随的尾巴endl; which you probably did not mean to include. 您可能并不打算包括在内。 std::endl is a function which is used when printing to an output stream; std :: endl是在打印到输出流时使用的功能; usually you'll see cout << ... << endl; 通常您会看到cout << ... << endl; , but otherwise it should not be used. ,但否则不应使用。

std::endl , as used as a stream manipulator, is actually a function. std::endl用作流操纵器,实际上是一个函数。

You probably achieve a similar or related error message by doing this 通过执行此操作,您可能会获得类似或相关的错误消息

 void f();   // don't need to define f()

 int main()
 {
      f;    //   should be f() to call the function
 }

So remove the statement endl; 因此,删除endl;语句endl;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM