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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:04:46+00:00 2026-06-14T10:04:46+00:00

I am doing a homework for my Systems Programming course. I have to implement

  • 0

I am doing a homework for my Systems Programming course.
I have to implement a University simulation.
I have a Course abstract class, and child class of it ComputerScienceCourse (and a bunch of other child classes that don’t affect what I’m going to ask).
and I have a Student abstract class, and child class of it ComputerScienceStudent (and a bunch of other child classes that don’t affect what I’m going to ask).
In the ComputerScienceCourse child class there is a function:

void teach(){
 for(i = all students that take this course [stored in a vector of pointers to Student objects, which is a member field of the CSCourse child class, called students]){
  this->students.at(i)->study(*this);
 }
}

This function calls study function for all students that have taken this class. The function is a member function of child class CSStudent

void study(Course &c){
 if(this->failedclass){
  c.removeStudent(this)
 }
}

Now when I check the output, the loop in the teach function does not call the study function for all the students within.
For example, if I have 4 students doing this course, sometimes it would call the study function of only the first three, sometimes it calls the function for the first and the last student… varies.
What could be causing the for loop to not call ALL students study functions?!
Here’s the full code for the teach function:

    for(unsigned int i=0; i<this->studentMembers.size(); i++){

    this->studentMembers.at(i)->study(*this);

}
  • 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-14T10:04:48+00:00Added an answer on June 14, 2026 at 10:04 am

    The problem seems to be that when a student fails a course, the contents of the vector get modified. Removing things from a vector while you’re iterating through its contents is tricky to get right. Seems like a more appropriate data model here would have the instructor remove students who fail, which would also make this problem much more tractable. So teach everyone, and then go through the list again to remove students who failed.

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

Sidebar

Related Questions

I'm doing a Systems Programming homework. I have to implement a university. I have
newbie doing Java homework here. I have one class named Album which contains the
For my systems programming class we're doing a lot of programming in C and
This is a homework I have for my Operative Systems class... This program sums
I am doing my homework for my visual basic class. I have most of
I am doing homework but I have problem with non-RestFul routes. My spec is:
I am doing a homework assignment for my summer OO class and we need
I am doing a homework assignment for my summer OO class and we need
I'm doing some homework and while I have some experience with SML, Haskell has
Me and my friend having a problem while doing a homework assignment. We have

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.