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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:33:06+00:00 2026-05-23T01:33:06+00:00

I have a class (Uniform) that has a constructor with 2 parameters, and a

  • 0

I have a class (Uniform) that has a constructor with 2 parameters, and a default copy constructor (it only contains int, floats, a std::vector and a std::map). I created a

std::vector<Uniform> uniforms

that I want to fill using the

uniforms.push_back()

line. I use this code to do that (the 2nd line is just here to test the copy constructor, as it currently fails)

Uniform uni(uniform_name,type);
Uniform uni2=uni;
uniforms.push_back(uni2);

The default constructor works fine, the "uni2=uni" compiles without problem (so the default copy constructor is OK too), but the push_back returns (using g++ as a compiler):

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/ext/new_allocator.h:108:9: erreur: no matching function for call to ‘Uniform::Uniform(const Uniform&)’

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../include/c++/4.6.0/ext/new_allocator.h:108:9: note: candidates are:

./inc/uniform.h:16:5: note: Uniform::Uniform(std::string, Uniform_Type)

./inc/uniform.h:16:5: note: candidate expects 2 arguments, 1 provided

./inc/uniform.h:14:7: note: Uniform::Uniform(Uniform&)

./inc/uniform.h:14:7: note: no known conversion for argument 1 from ‘const Uniform’ to ‘Uniform&’

Thanks 🙂

  • 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-23T01:33:07+00:00Added an answer on May 23, 2026 at 1:33 am

    When you say “default copy constructor” (which generally makes little sense), I assume you mean “implicitly-declared copy constructor” or “compiler-provided copy constructor”

    The exact signature of the compiler-provided copy constructor will depend on the contents of your Uniform class. It could be Uniform::Uniform(const Uniform &) or Uniform::Uniform(Uniform &) depending, again, on the details of Uniform (which you didn’t provide).

    For example, if your Uniform includes a subobject (base or member) of type T, whose copy constructor is declared as T::T(T &) (no const), then Uniform‘s implicit constructor will also be implicitly declared as Uniform::Uniform(Uniform &) (no const).

    A full specification can be found in the language standard (12.8/5)

    The implicitly-declared copy
    constructor for a class X will have
    the form

    X::X(const X&)

    if

    — each
    direct or virtual base class B of X
    has a copy constructor whose first
    parameter is of type const B& or const
    volatile B&, and

    — for all the
    nonstatic data members of X that are
    of a class type M (or array thereof),
    each such class type has a copy
    constructor whose first parameter is
    of type const M& or const volatile
    M&.

    Otherwise, the implicitly
    declared copy constructor will have
    the form

    X::X(X&)

    An
    implicitly-declared copy constructor
    is an inline public member of its
    class.

    The push_back implementation needs Uniform::Uniform(const Uniform &), but something in your class causes it to be Uniform::Uniform(Uniform &). Hence the error. There’s no way to say what it is without seeing the definition of your Uniform.

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

Sidebar

Related Questions

No related questions found

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.