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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:40:03+00:00 2026-05-17T06:40:03+00:00

I have the following small code: template <typename T> class V { public: T

  • 0

I have the following small code:

template <typename T>
class V
{
    public:
        T x;

    explicit V(T & _x)
    :x(_x){}

};

int main()
{
    V<float> b(1.0f); // fails
    return 0;
}

And it happens to fail. The message returned by g++ 4.4.5 is:

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
../main.cpp: In function ‘int main()’:
../main.cpp:19: error: no matching function for call to ‘V<float>::V(float)’
../main.cpp:10: note: candidates are: V<T>::V(T&) [with T = float]
../main.cpp:6: note: V<float>::V(const V<float>&)

The thing is… whence the second constructor came? I really have no clue…

  • 1 1 Answer
  • 2 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-17T06:40:03+00:00Added an answer on May 17, 2026 at 6:40 am

    Other answers discuss why you’re getting a compile-time failure (which is what most questions are about when such failures are the most prominent part of the question). However. regarding your explicit question, “whence the second constructor came?”:

    12.8/4 “Copying class objects” of standard says:

    If the class definition does not explicitly declare a copy constructor, one is declared implicitly.

    If you’d like to avoid the implicit copy-ctor from being used, one of a few ‘non-copyable’ idioms can be used (such as boost::noncopyable): http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-copyable_Mixin

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

Sidebar

Related Questions

I have following code that displays an Image with letters, public class MainActivity extends
I have the following code snippet of a small Thread class I am trying
Work on this small test application to learn threading/locking. I have the following code,
I'm doing a small app in Excel, and I have the following code when
I have a small I have just written which uses the following uri template.
I have a small doubt I have following code bool res= false; if(cond1) {
I have a very small header that contains the following code. The code compiles
I have the following code slightly modified from the Visual Studio 2010 css template.
I have the following code on my model: has_attached_file :photo, :styles => { :small
I have a template class, what I want to do are the following Make

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.