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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:13:09+00:00 2026-06-05T13:13:09+00:00

I have multiset < Class1 > myset ; so I create a new object:

  • 0

I have multiset < Class1 > myset;
so I create a new object: Class1* c1 = new Class1();
I was expecting to be able to myset.insert(c1) or myset.insert(new Class1()); but none of them work.

class Class1{
 int time;
public:
  CLass1(int t) : time(t) {}
  bool operator<(Class1 &c2) {return time < c2.time;}
}

How is inserting objects different from inserting integers? I was able to insert ints.

  • 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-05T13:13:10+00:00Added an answer on June 5, 2026 at 1:13 pm

    In your definition, myset holds Class1 object, while c1 is a pointer to Class1 object. So that’s the type problem.

    Either you use myset to hold pointer to objects — multiset<Class1 *> myset, or copy the newly created object into myset — myset.insert(*c1); delete c1;. Note that container requires object must be copyable and assignable, and should be comparable by implementing operator<.

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

Sidebar

Related Questions

I have a std::multiset which stores elements of class A . I have provided
have written this little class, which generates a UUID every time an object of
have not tested on windows. but in ubuntu when u disconnect from the network,
I have to partition a multiset into two sets who sums are equal. For
I have this: struct myClass{ multiset<string,binPred<string> > values ; myClass(const char param1, const char
I have: 1) a starting set, a multiset, e.x. { x, y, z, z
New to Salesforce and having some issues with the Approval Process setup. I have
Have some code: using (var ctx = new testDataContext()) { var options = new
Have one Doubt In MVC Architecture we can able to pass data from Controller
Have searched for the answer but no joy, so here goes... I'm working on

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.