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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:43:32+00:00 2026-06-14T15:43:32+00:00

This is my Code #ifndef INTLIST_H_INCLUDED #define INTLIST_H_INCLUDED #include <iostream> using namespace std; class

  • 0

This is my Code

#ifndef INTLIST_H_INCLUDED
#define INTLIST_H_INCLUDED
#include <iostream>
using namespace std;

class intList
{
    int upper_bound;
    int arr[0];
    public:
        intList(){ arr[0] = 0; upper_bound = 0; }
        void append(int x);
        void sort();
        friend ostream & operator << (ostream &, intList&);
        inline int len(){ return upper_bound; }
        inline int &operator [](int x){ return arr[x]; }
    private:
        void increment(int *a, int &l);
        void swap(int &a, int &b);
};

void intList::swap(int &a, int &b)
{
    int temp = a;
    a = b;
    b = temp;
}

void intList::increment(int *a, int &b)
{
    b++;
    a[b] = 0;
}

void intList::append(int num)
{
    arr[upper_bound] = num;
    increment(arr, upper_bound);
}

void intList::sort()
{
    for(int i = 0; i < upper_bound; i++)
    {
        int minLoc = i;
        for(int j = i+1; j<upper_bound; j++)
        {
            if(arr[j] < arr[minLoc])
                minLoc = j;
        }
        if(minLoc != i)
            swap(arr[i], arr[minLoc]);
    }
}

ostream& operator << (ostream & dout, intList &a)
{
    dout << "[ ";
    for(int i = 0; i<a.upper_bound-1; i++)
        dout << a.arr[i] << ", ";
    dout << a.arr[a.upper_bound-1] << " ]";

    return dout;
}

#endif // INTLIST_H_INCLUDED

The Code does its work perfectly fine. But at the end the Program Crashes. Giving some error like
process returned -1073741819 (0xC0000005) execution time : some seconds.

Just didn’t get where am I going wrong.

  • 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-14T15:43:34+00:00Added an answer on June 14, 2026 at 3:43 pm

    Your code has several problems.

    For example, you have a fixed array of 0 size. If you want a dynamically growable array, you can use std::vector: you can add new items at the end of the vector (dynamically resizing it) using push_back() method:

    #include <vector>
    
    // Start with an empty vector
    std::vector<int> v;
    
    // Add some items to it
    v.push_back(10);
    v.push_back(20);
    ....
    

    Note also that in header files it’s not good to insert a using namespace std;. In this way you pollute the global namespace with STL classes, which is bad. Just use std:: prefix in header files.

    Moreover, if you want to print the class content to an output stream, you may want to take the class as a const reference, since instances of the class are input parameters (you observe them and print their content to the stream):

    std::ostream& operator<<(std::ostream& os, const IntList& a)
    {
       ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code main.cpp #include <iostream> #include functs.h using namespace std; int main()
Given this code sample: complex.h : #ifndef COMPLEX_H #define COMPLEX_H #include <iostream> class Complex
#ifndef DELETE #define DELETE(var) delete var, var = NULL #endif using namespace std; class
I have this code: #ifndef FUNCSTARTER_H #define FUNCSTARTER_H #endif // FUNCSTARTER_H #include <QObject> class
hope someone can answer this. Here is some sample code. namespace std { #ifdef
Why can't I get anything to display with this code? #include <iostream> #include GL/glfw.h
#ifndef NULL #define NULL NULL #endif This code compiles in gcc with no warnings/errors.
My code is as below: Interpolation.h #ifndef INTERPOLATOR #define INTERPOLATOR #include <vector> #include <utility>
I have the following code: Master.h #ifndef MASTER_H #define MASTER_H class Master { friend
I have the following seemingly innocuous piece of code: #ifndef UI_H #define UI_H #include

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.