Without the name, it runs fine. I read up that adding const before new could solve my problem, but it doesn't. Any ideas?

include <iostream>

include <string.h>

using namespace std;

class Player {
    int Health, *Strength, *Speed, *Accuracy, *Defense;
    char *Name[80];
    public:
        Player (char, int, int, int, int, int);
        ~Player ();
        void Manip (int, int, int, int, int);
        void Output ();
};

Player::Player (char Nme, int Hth, int Str, int Spd, int Acc, int Dfn) {
    Name = new char[80];
    Health = new int;
    Strength = new int;
    Speed = new int;
    Accuracy = new int;
    Defense = new int;
    *Name[80] = Nme[];
    *Health = Hth;
    *Strength = Str;
    *Speed = Spd;
    *Accuracy = Acc;
    *Defense = Dfn;
}

Player::~Player () {
    delete Health;
    delete Strength;
    delete Speed;
    delete Accuracy;
    delete Defense;
}

void Player::Manip (int A, int B, int C, int D, int E) {
    *Health = *Health + A;
    *Strength = *Strength + B;
    *Speed = *Speed + C;
    *Accuracy = *Accuracy + D;
    *Defense = *Defense + E;
}

void Player::Output () {
    cout << "\nHealth: " << *Health << endl;
    cout << "Strength: " << *Strength << endl;
    cout << "Speed: " << *Speed << endl;
    cout << "Accuracy: " << *Accuracy << endl;
    cout << "Defense: " << *Defense << endl << endl;
}

int main () {
    Player Player1 ("Player One", 100, 20, 20, 20, 20), Player2 ("Player Two", 500, 100, 100, 100, 100);
    Player1.Player::Output();
    Player2.Player::Output();
    Player1.Player::Manip (10, 10, 10, 10, 10);
    Player2.Player::Manip (20, 10, 10, 20, 10);
    Player1.Player::Output();
    Player2.Player::Output();
    return 0;
}

Please use the Code button above the editor to maintain formatting of and line-number your code.

The error is a missing * before Health in the first line of class Player.

That said, why do you want the inefficiency of all those pointers to integers for your class members? Just declare them int, instead of int *, and assign them directly instead of allocating, deallocating and dereferencing the pointers everywhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.