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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:29:31+00:00 2026-06-03T18:29:31+00:00

This add function will take a single parameter which will be the item to

  • 0

This add function will take a single parameter which will be the item to be added to the array. I’ve tried using a for loop but it didn’t work as I expected it to. I’m currently just trying to do something like this:

    bool homeworklist::add (homework h)
    {
    int i = 0;

    if(current_size < LIST_MAX){

        current_size += 1;

        list[i] = h;

        ++i;

        return true;
    }
    return false;
}

current_size is just a counter.
list is a array that belongs to a homeworklist class
list takes in homework objects.
The function returns true if the object was added succesfully and false if it wasnt added correctly.

  • 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-03T18:29:33+00:00Added an answer on June 3, 2026 at 6:29 pm

    The variable i is local, which means each time you call this function, it is initialized to 0, due to this line:

    int i = 0;
    

    This in turn means in the subsequent if statement, you are assigning the element to the first location, everytime.

    You could make i a class member, just like how you might have declared current_size. Or might be you could just make use of current_size itself.

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

Sidebar

Related Questions

I need to add authentication to this function: function multiRequest($data, $options = array()) {
When I request this function //Add the content to the database function articleadd() {
I have written a function for deleting object preiodically. function add(variable, expireSecond){ this.list[variable] =
I made this simple function to filter the data. I add the symbols that
I'm looking to add double buffering to a drawing function like this. dc =
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
I'm starting to learn Backbone with this simple example: <div id=counter>unkown</div> <button id=add-button>ADD</button> (function($){
I'm trying to implement a custom aggregate function in Postgres which will average directions
If I have a selector like $add, I can do this: $add.click(function () {.....
I need a function that will take in a list of characters and numbers,

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.