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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:40:10+00:00 2026-05-31T23:40:10+00:00

I am working on a class for an existing main program, and it is

  • 0

I am working on a class for an existing main program, and it is throwing a segfault on the delete [] line. I am not quite sure why it is doing this. I have asked the professor and I was told to reread the section about how pointers get corrupted. Any help would be appreciated! The relevant code is below.

From the main:

Point* v = new Point[nVertices];
for (int i = 0; i < nVertices; ++i)
  in >> v[i].x >> v[i].y;
Asteroid aster1 (nVertices, v);
delete [] v;

The class section for asteroid’s constructor:

Asteroid::Asteroid(int nVertices, Point vertexPoints[]){
    numVertices = nVertices;
    for (int i = 0; i < numVertices; i++){
        vertices[i] = vertexPoints[i];
    }
}

And the .h section if that is significant:

class Asteroid{
    int numVertices;
    Point vertices[];
public:
    //Attributes
    Asteroid (int,Point*);
  • 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-31T23:40:12+00:00Added an answer on May 31, 2026 at 11:40 pm

    It looks very unlikely that the segfault is at the delete[] line. Much more likely that it occurs in the Asteroid constructor, as you are already attempting to access vertices before you’ve created the array which is supposed to contain them.

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

Sidebar

Related Questions

I am working on the redesign of an existing class. In this class about
I'm currently working on a large implementation of Class::DBI for an existing database structure,
Does anyone have a working class or function to create the hashed email that
I have a working wrapper class for Dallmeier camera devices, It contains a callback
I have a very old, very very large, fully working, C program which plays
I have been working on this Tab View and I finally got it working
I am working on an existing code. In one of the classes I have
i'm reposting this question because i'm not sure if i asked it correctly before.:)
I'm working on modifying part of an existing Rails app to use the Class-Table-Inheritance
I’m working with an existing schema that I’d rather not change. The schema has

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.