Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9041693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:17:57+00:00 2026-06-16T10:17:57+00:00

I was simply curious about what would happen if I called operator<< on std::cout

  • 0

I was simply curious about what would happen if I called operator<< on std::cout explicitly because I learnt that a.operator() is exactly the same as a(). So I do it and it prints something weird:

#include <iostream>

using std::cout;

int main()
{
    cout.operator<<("Hello World");
}

Output: 0x80486a0

Oddly, it outputs an address (the address may be different for you but it should still be an address). I’m thinking this is the address of the string so I try dereferencing it to get it to output the string:

*( cout.operator<<("Hello World") );

But I get a very long error

no match for operator* in '*std::cout.std::basic_ostream<...

I think this is pretty weird. Nothing of the std::cout definition would lead me to believe this would cause any different behavior; also given the fact that explicitly calling the operator function makes no difference (or should at least).

So why am I getting this output? Why am I receiving an address instead of the string itself when calling the operator explicitly? Is this even the address in memory or just garbage output? Any responses are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:17:58+00:00Added an answer on June 16, 2026 at 10:17 am

    The output operator for built-in strings, i.e., the on taking a char const* as argument, isn’t a member of std::ostream. The operator taking a char const* is a non-member function would be called as

    operator<< (std::cout, "Hello World");
    

    There is, however, a member taking a void const* which formats the value of the pointer using hex notation. This member is the best match when passing any pointer explicitly to a member operator<< () of std::ostream.

    Dereferencing the results of a the operator<<() doesn’t work: The operators return a std::ostream& which doesn’t have a unary operator*() overloaded. If you meant to dereference the argument, you’d call it like so:

    std:cout.operator<< (*"Hello World");
    

    However, this would just derference the char const* the string literal decays to, yielding an individual character H. The character output function isn’t a member function, either, while the output operators for integers are, i.e., it would print character value of H. For a system using ASCII it would be 72.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm curious about using two APIs that both utilize OAuth2 authentication in the same
I am new to ClearCase UCM and I am simply curious about Projects/Streams. I
Considering that everyone is always worried about User Data (And Rightly So), would it
I am currently learning jQuery, and I am curious about something. For functions that
I was curious about how the MongoDB plugin for Grails would handle relationships. In
I have a collection of objects and am curious about the way you would
I am curious about developing my own Simple Hashing mechanism. I would like to
I just learned about comet pattern(Long polling) and very curious to implement a simple
I'm curious about the <merge> and <include> tags in Android XML-layouts. I've read two
Just curious about SQL syntax. So if I have SELECT itemName as ItemName, substring(itemName,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.