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 8864717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:19:00+00:00 2026-06-14T16:19:00+00:00

Earlier today I tried to compile code similar to: class example { public: example(const

  • 0

Earlier today I tried to compile code similar to:

class example
{
public:
    example(const char (&in_data)[6]);
};

example foo()
{
    return "ABCDE";
}

On GCC, and it complained about there being no conversion to example on the return line. I was able to initialize objects of type example in other places with code such as

example bar("ABCDE");

just fine. All this worked fine when compiled in VS2010 as well.

Now, my question is, should this have worked, or is this some visual studio compiler extension? It seems to me that this should work due to the non-explicit constructor…

I don’t have the exact error message right now because I’m not at work, but it’s really bothering me.

  • 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-14T16:19:01+00:00Added an answer on June 14, 2026 at 4:19 pm

    I can’t see any reason why the implicit conversion shouldn’t work. Trying with gcc, clang, and EDG, only gcc fails. I’d guess this is a gcc error. That said, gcc seems to be keen to create a char const* out of an array reference. This code

    example f()
    {
        char const (&array)[6] = "abcde";
        return array;
    }
    

    yields this error:

    implicit.cpp: In function ‘example f()’:
    implicit.cpp:10:12: error: could not convert ‘(const char*)array’ from ‘const char*’ to ‘example’
         return array;
                ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this earlier today: public interface IFoo { IEnumerable<int> GetItems_A( ref int somethingElse
Earlier today I tried to do this: Example 1: <?php echo $myVar || rawr;
Working with developer phone earlier, today i tried my hand on emulator i do
Earlier today I asked similar problem to find the maximum element which is common
This code was working earlier today, then randomly stopped, something must of changed, but
I asked a question earlier today ( Methods of Managing Source Code ) as
earlier today I asked this question . So since moq creates it's own class
earlier today this code worked as I wanted it to. Now it doesn't. I
I was taken aback earlier today when debugging some code to find that something
Earlier today I tried installing the MyImouto image board software on my Apache server.

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.