Skip to main content
deleted 27 characters in body; edited title
Source Link
Drew Dormann
  • 65.4k
  • 14
  • 133
  • 200

C++ class inheritancainheritance variables

I'm working on a game, and I want to store the charachtercharacter belongs to a unit inside the class that defines the units. (as objects)

This is the defining class. (I use inheritance)

class Units
{
    public:
       char indicator;

        Units();
        virtual ~Units();
    protected:
    private:
};

Units::Units (){}
Units::~Units (){}


class WoodenBoxClass: public Units
{
    public:
        WoodenBoxClass.indicator = 'B';
};

During the compilation, when "WoodenBoxClass.indicator = 'B';" comes, I get an error message:

50|error: expected unqualified-id before '.' token

What should I do? The main question is that how can I reach that the "indicator" variable is the same to every "WoodenBoxClass" object?

Thanks for the help!

C++ class inheritanca variables

I'm working on a game, and I want to store the charachter belongs to a unit inside the class that defines the units. (as objects)

This is the defining class. (I use inheritance)

class Units
{
    public:
       char indicator;

        Units();
        virtual ~Units();
    protected:
    private:
};

Units::Units (){}
Units::~Units (){}


class WoodenBoxClass: public Units
{
    public:
        WoodenBoxClass.indicator = 'B';
};

During the compilation, when "WoodenBoxClass.indicator = 'B';" comes, I get an error message:

50|error: expected unqualified-id before '.' token

What should I do? The main question is that how can I reach that the "indicator" variable is the same to every "WoodenBoxClass" object?

Thanks for the help!

C++ class inheritance variables

I'm working on a game, and I want to store the character belongs to a unit inside the class that defines the units. (as objects)

This is the defining class. (I use inheritance)

class Units
{
    public:
       char indicator;

        Units();
        virtual ~Units();
    protected:
    private:
};

Units::Units (){}
Units::~Units (){}


class WoodenBoxClass: public Units
{
    public:
        WoodenBoxClass.indicator = 'B';
};

During the compilation, when "WoodenBoxClass.indicator = 'B';" comes, I get an error message:

50|error: expected unqualified-id before '.' token

What should I do? The main question is that how can I reach that the "indicator" variable is the same to every "WoodenBoxClass" object?

Source Link
Zoltán Schmidt
  • 1.4k
  • 2
  • 31
  • 51

C++ class inheritanca variables

I'm working on a game, and I want to store the charachter belongs to a unit inside the class that defines the units. (as objects)

This is the defining class. (I use inheritance)

class Units
{
    public:
       char indicator;

        Units();
        virtual ~Units();
    protected:
    private:
};

Units::Units (){}
Units::~Units (){}


class WoodenBoxClass: public Units
{
    public:
        WoodenBoxClass.indicator = 'B';
};

During the compilation, when "WoodenBoxClass.indicator = 'B';" comes, I get an error message:

50|error: expected unqualified-id before '.' token

What should I do? The main question is that how can I reach that the "indicator" variable is the same to every "WoodenBoxClass" object?

Thanks for the help!