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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:11:05+00:00 2026-05-29T08:11:05+00:00

I have two structs (part of the assignment). A list of one — Activity,

  • 0

I have two structs (part of the assignment). A list of one — Activity, contained in the other — Process. Then, several of the parent Process struct are contained in a priority queue.

struct Activity {
public:
    int time;
    string type;
    Activity(int newTime, string newType):
    time(newTime),type(newType){}
};

struct Process {
public:
    string PID;
    int arrivalTime;
    int priority;
    list<Activity> activityQueue;
    Process( string newPID, int newTime, int newPriority, list<Activity>
         newActivityQueue):
    PID(newPID),arrivalTime(newTime), priority(newPriority), 
         activityQueue(newActivityQueue){}

};

I get the following error…

main.cpp:206:61: error: passing ‘const std::list<Activity>’ as ‘this’ argument of
‘void std::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Activity,
_Alloc = std::allocator<Activity>, std::list<_Tp, _Alloc>::value_type = 
Activity]’ discards qualifiers [-fpermissive]

…when I attempt to push_back an Activity to a Process’s activityQueue.

Activity currentActivity = cpuQueue.top().activityQueue.back();
currentActivity.time--
cpuQueue.top().activityQueue.push_back(currentActivity);
  • 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-29T08:11:07+00:00Added an answer on May 29, 2026 at 8:11 am

    std::priority_queue<T>::top() returns a const reference to the top item: this is so you can’t mutate it in-place and break the ordering constraints.

    If you’re happy that the activity list is an implementation detail that won’t affect the position of a process in the cpu queue, you could just make Process::activityQueue mutable.

    Otherwise, you should pull the process out of the queue, modify it, and re-add.

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

Sidebar

Related Questions

My problem is deleting a node from linked list. I have two structs :
I want to have two structs that can contain each other. Here is an
So, I have two structs: struct coordinate { float x; float y; } struct
I have a program that compares variables from two structs and sets a bit
The code is in C. I have two type of objects ( structs )
I have two window form applications written in C, one holds a struct consisting
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two structs: template <typename T> struct Odp { T m_t; T operator=(const
I have two structs, in which I'm trying to overwrite a method in the
I have two structs pointers to pointers typedef struct Square { ... ... }Square;

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.