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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:50:04+00:00 2026-05-24T23:50:04+00:00

My execution program won’t work properly, for whatever reason. #include <QtCore/QCoreApplication> #include <tinyxml/tinyxml.h> #include

  • 0

My execution program won’t work properly, for whatever reason.

#include <QtCore/QCoreApplication>
    #include <tinyxml/tinyxml.h>
    #include "classowner.h"
    #include "character.h"

    int main(int argc, char *argv[])
    {
        Character * holland = new Character("Holland", HUMAN, MALE);
        delete &holland;
        std::cout << "Hello, World!" << std::endl;

        return 0;
    }

All my output states is that the program won’t execute properly. The output doesn’t display, however when I don’t allocate the object, it will. Obviously, it’s the object. What am I doing wrong?

Update

It appears the problem may be something more than deleting and allocating memory. Thus, I’m going to post the implementation behind the Character class.

Header:

#include <iostream>
#ifndef CHARACTER_H
#define CHARACTER_H

enum Race {HUMAN, DARK_ELF};
enum Gender {MALE, FEMALE};
class Character
{
public:
    Character();
    Character(std::string char_name, Race char_race, Gender char_gender);
    ~Character();

    int get_id() { return this->char_id; }
    std::string get_name() { return this->name; }
    Race get_race() { return this->race; }
    Gender get_gender() { return this->gender; }

private:
    int char_id;
    static int * char_count;
    std::string name;
    Race race;
    Gender gender;
};



  #endif // CHARACTER_H

//Source:

#include "character.h"
#include <iostream>

int * Character::char_count = 0;

Character::Character()
{
    this->char_id = *char_count;
    char_count++;
}

Character::Character(std::string char_name, Race char_race, Gender char_gender)
{
    this->char_id = *char_count;
    char_count++;
    this->name = char_name;
    this->race = char_race;
    this->gender = char_gender;
}

Character::~Character()
{

}
  • 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-24T23:50:05+00:00Added an answer on May 24, 2026 at 11:50 pm

    First of all, you try to dereference a null pointer:

    int * Character::char_count = 0;
    

    Both constructors of class Character do this

    this->char_id = *char_count;
    

    and that’s an attempt to dereference a null pointer. That code makes no sense to me, I guess you could just use int instead of pointer:

    int Character::char_count = 0;
    //then
    this->char_id = char_count;
    

    Also here:

    Character * holland = new Character("Holland", HUMAN, MALE);
    

    you create an object of type class Character. You have to delete that object through a pointer to class Character – the pointer should have type Character*. Instead you try to use delete on a pointer of type Character**and that leads to undefined behavior.

    So instead of

    delete &holland;
    

    you have to use

    delete holland;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the course of my program execution, a number of threads are started. The
I need to find the total timings for the execution of a program over
Is it possible to create a complete fork of a 'PROGRAM' in execution into
My program has two threads: Main execution thread that handles user input and queues
During execution, how can a java program tell how much memory it is using?
Will the following program cause any problem during compiling and execution process? class A{
How do I get my C# program to sleep (pause execution) for 50 milliseconds?
I just found out that my program is losing 5% execution speed when it
Typically when you run any program, during execution time what are different storages available
I have a C++ program which, during execution, will allocate about 3-8Gb of memory

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.