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

  • SEARCH
  • Home
  • 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 3271998
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:46:56+00:00 2026-05-17T18:46:56+00:00

Someone has given me the following C++ code snippet to try out – and

  • 0

Someone has given me the following C++ code snippet to try out – and now I have lost contact with them (its a long story). Anyway, it won’t compile – I get an error

error C2512: ‘mstream’ : no appropriate default constructor available

Can anyone explain why, and what is needed to fix it.

class mstream : private ostream
{
  public:

  mstream& operator << (char *value)
  {
    printf ("[%s]\n", value);
    return *this;
  }
  mstream& operator << (int value)
  {
    printf ("[%u]\n", value);
    return *this;
  }

};
mstream g_mcout;

EDIT: Oops, missed this out…

ostream& mcout ()
{
  return g_mcout;
}
ostream& SgDebug ()
{
  return g_mcout;
}

FYI: the reason for this strange looking code is all to do with merging a C++ with a C program. The printf()’s will actually be changed to my_printf()’s which do a wide variety of custom things.

  • 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-05-17T18:46:57+00:00Added an answer on May 17, 2026 at 6:46 pm

    ostream has no default constructor; the implicitly created default constructor for mstream is invalid because of it. You need to provide the ostream with a stream buffer:

    class mstream : private ostream
    {
    public:
        mstream() :
        ostream(/* whatever you want */)
        {}
    
        /* Maybe this is more appropriate:
    
        mstream(std::streambuf* pBuffer) :
        ostream(pBuffer)
        {}
    
        */
    
        // ...
    };
    

    So it can construct. What you put there depends on what you’re trying to do.

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

Sidebar

Related Questions

I have an XML-File, which has the following structure: <mediawiki ...> <siteinfo>...</siteinfo> <page> <title>The
I have the following test code #include <iostream> template <typename T> struct PS {
I'm hoping someone has seen this before because I can't for the life of
I'm hoping that someone has found a way of doing this already or that
I'm betting that someone has already solved this and maybe I'm using the wrong
I'm wondering if someone has already built a system for threaded comments (for lack
I'm trying to write a script that informs the user when someone has logged
The print functionality of Excel (using VBA) is extremely slow. I'm hoping someone has
Has someone successfully overridden the scoring of documents in a query so that the
Has someone ever measured performance of Sequential Guid vs. Standard Guid when used as

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.