5 Replies - 3056 Views - Last Post: 20 July 2012 - 04:18 AM Rate Topic: -----

#1 wkwkwkwk1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-February 12

error: statement cannot resolve adress of overloaded function

Posted 18 July 2012 - 05:01 AM

When I insert this code:
#include <iostream.h>

int main()
{
cout << "Hello there.\n";
cout << "Here is 5:" << 5 << "\n";
cout << "The manipulator endl writes a new line to the screen\n";
endl;
cout << "Here is a big number:" << "70000\n";
return 0;
}


I get this message:
error: statement cannot resolve adress of overloaded function

I am sure the problem is with "endl" function, since when I remove it, it works just fine.

I have tried to change from "\t" to "\n", altough I don't know if there is a difference, I have googled the error, and I have tried to use the insertion operator (<<) instead of using ";" before "endl".

Thanks in advance,
wkwkwkwk1

By the way, I am using Code::Blocks

Is This A Good Question/Topic? 0
  • +

Replies To: error: statement cannot resolve adress of overloaded function

#2 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: error: statement cannot resolve adress of overloaded function

Posted 18 July 2012 - 05:16 AM

endl is a function, you either need to call it explicitly by giving it the stream, to which you want to print the newline, as an argument or you need to use it as an operand to <<.

Just writing the name of a function as a statement on its own without calling it is a no-op. And in cases of overloaded functions it's actually a compile-error as you see here.
Was This Post Helpful? 1
  • +
  • -

#3 wkwkwkwk1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-February 12

Re: error: statement cannot resolve adress of overloaded function

Posted 18 July 2012 - 06:02 AM

View Postsepp2k, on 18 July 2012 - 01:16 PM, said:

endl is a function, you either need to call it explicitly by giving it the stream, to which you want to print the newline, as an argument or you need to use it as an operand to <<.

Just writing the name of a function as a statement on its own without calling it is a no-op. And in cases of overloaded functions it's actually a compile-error as you see here.


Thank you very much. How can I give it the stream, or use it as an operand to <<?

Thanks in advance,
wkwkwkwk1
Was This Post Helpful? 0
  • +
  • -

#4 wkwkwkwk1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-February 12

Re: error: statement cannot resolve adress of overloaded function

Posted 20 July 2012 - 01:34 AM

Can anyone help me? I'd like to keep learning C++, even at a slow rate, so I'd like some help.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7915
  • View blog
  • Posts: 26,425
  • Joined: 05-May 12

Re: error: statement cannot resolve adress of overloaded function

Posted 20 July 2012 - 01:42 AM

What have you tried since the time sepp2k had answered your question?

What other research have you done about endl? Did you even try to read the documentation for endl, or are you just cutting and pasting somebody else code and not bothering to understand?
Was This Post Helpful? 0
  • +
  • -

#6 wkwkwkwk1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-February 12

Re: error: statement cannot resolve adress of overloaded function

Posted 20 July 2012 - 04:18 AM

I just made it, I wrote:
#include <iostream.h>

int main()
{
cout << "Hello there.\n";
cout <<     "Here is 5:" << 5 << "\n";
cout << "The manipulator endl writes a new line to the screen\n";
cout << endl;
cout << "Here is a big number:" << "70000\n";
return 0;
}



I put endl after cout. I only now realized what he meant.
Where the code came from:


Thanks anyways.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1