简体   繁体   中英

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. A switch inside a while loop.

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. I have damage declared as an int and set to 0 before trying to change it to the attack value. 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

You have a trailing endl; which you probably did not mean to include. std::endl is a function which is used when printing to an output stream; usually you'll see cout << ... << endl; , but otherwise it should not be used.

std::endl , as used as a stream manipulator, is actually a function.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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