无法解析符号“值”

时间:2019-05-19 21:17:36

标签: c++ visual-studio

标题有问题,我在继承主类的几个类中使用了它。我有些困惑,为什么它不起作用,但是除了我尝试在以后的课程中使用皮肤类型,肢体或特征值时,其他一切似乎都还可以。

我修复了目前可以看到的大多数其他错误,但是当我尝试合并这些错误时,只是对每个说同样的事情而抛出错误,无法为其定义值。

#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <memory>
#include <map>

using namespace std;

void pause ()
{
    cout << endl << "[Enter] to continue.";
    cin.get();
}

///////////////////////////////////////////////////////////////////////////////////////

class Animal 
{
public:

    enum {
        Vertebrae = 1,
        Skull = 2,
        Ears = 4,
        Cold = 8,
        Tail = 16,
        Nocturnal = 32,
    };
    enum {
        Legs = 1,
        Wings = 2,
        Fins = 4,
        Arms = 8,
        Calcific = 16,
    };
    enum {
        Scales = 1,
        Fur = 2,
        Wool = 4,
        Skin = 8,
        Feathers = 16,
    };

protected:

    string name;


    unsigned traits{};
    void set_traits (unsigned value)
    {
        traits |= value;
    }

    unsigned limbs{};
    void set_limbs (unsigned value)
    {
        limbs |= value;
    }

    unsigned skintype{};
    void set_skintype (unsigned value)
    {
        skintype |= value;
    }

    Animal(const Animal&) = default;
    Animal& operator = (const Animal&) = default;

    Animal(Animal&&) noexcept;
    Animal& operator = (Animal&&) noexcept;

    virtual ~Animal() = default;

public:

    Animal () = default;
    Animal (const char* name_, unsigned traits_) : name (name_), traits(traits_) { }

    const string& get_name () const { return name; }

    bool has_spine () const { return traits & Vertebrae; }
    bool has_skull () const { return traits & Skull; }
    bool has_ears () const { return traits & Ears; }
    bool is_cold () const { return traits & Cold; }
    bool has_tail () const { return traits & Tail; }
    bool is_nocturnal () const { return traits & Nocturnal; }

    bool has_legs () const { return limbs & Legs; }
    bool has_wings () const { return limbs & Wings; }
    bool has_fins () const { return limbs & Fins; }
    bool has_arms () const { return limbs & Arms; }
    bool has_bones() const { return limbs & Calcific; }

    bool has_scales () const { return skintype & Scales; }
    bool has_fur () const { return skintype & Fur; }
    bool has_wool () const { return skintype & Wool; }
    bool has_skin () const { return skintype & Skin; }
    bool has_feathers () const { return skintype & Feathers; }
};

Animal::Animal (Animal&& other) noexcept
{
    operator = (other);
}

Animal& Animal::operator=(Animal&& other) noexcept
{
    if (this != &other)
    {
        traits = other.traits;
        limbs = other.limbs;
        skintype = other.skintype;
        other.traits = 0;
        other.limbs = 0;
        other.skintype = 0;
    }
    return *this;
}

class LeglessAnimal : public Animal
{
public:
    LeglessAnimal () = default;
};

set_limbs(value:Legs)语句中弹出错误

class LeggedAnimal : public Animal
{
public: 
    LeggedAnimal ()
    {
        set_limbs (value: Legs)
    }
    virtual size_t number_of_legs() const = 0;
};

在项目中进一步声明特征时,我也遇到类似的问题,不确定我需要更改什么,我尝试用几种不同的方式弄乱它。

0 个答案:

没有答案