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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:37:12+00:00 2026-06-14T07:37:12+00:00

I defined a class eventZone which is used in my class configuration class configuration

  • 0

I defined a class “eventZone” which is used in my class “configuration”

class configuration { ... QMap<QString, eventZone> zones ... }

Until rescently I succesfully used a for loop like saw

for(eventZone evz : config.zone.values()) { ... }

However this doesnt work since I implemented a copy constructor for eventZone (needed to serialize it and be able to save configurations)

The error I get is

/home/.../zonedisplay.cpp:43: erreur : no matching function for call to 'eventZone::eventZone(eventZone&)'

My new constructor has type :

explicit eventZone(const eventZone &cpy);

How to make those two coexist ?

  • 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-14T07:37:14+00:00Added an answer on June 14, 2026 at 7:37 am

    There is no reason to put explicit here. explicit‘s job is to prevent implicit conversions, but you don’t convert – you just copy. Remove it. It’s only needed for single-argument constructors that have parameters of a different type than the class type itself.

    Anyways, the usual idiom in C++ is to take references (unless you explicitly need copies), and that applies to the range-based for-loop too:

    for(auto const& e : config.zone.values())
      // do whatever with 'e'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use (*env)->RegisterNatives to add methods to a defined class which
Having a user defined class, like this: class Foo { public int dummy; public
I have been reviewing some code that looks like this: class A; // defined
This is an example of a user defined class I'd like to send from
I've defined Class A which has number of methods. Then I have this other
While you create a user defined class in Java, you do not specify it
scala> class A defined class A scala> trait B defined trait B Creating an
I defined next class with virtual properties: public class Order: BaseEPharmObject { public Order()
ImageView is defined in class named Third - (void)viewDidLoad { // Displays UIImageView UIImageView*
I have defined a class A and derived a new class B from A

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.