gpt4 book ai didi

c++ - X 类型的值不能用于初始化 X 类型的实体

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:40:41 31 4
gpt4 key购买 nike

struct Value {
struct Array;
struct Dict;
struct Primitive;

Value() {}
virtual ~Value() {}

virtual Array * asArray() { assert(false); }
virtual Dict * asDict() { assert(false); }
virtual Primitive * asPrimitive() { assert(false); }

int asInt();
double asDouble();
std::string asDate();
std::string asString();
};

struct Value::Array : public Value {
std::vector<Value> m_data;

Array() {}
~Array() {}

Value::Array * asArray() {
Value::Array * result = this;
return result;
}
};

声明 Value::Array * result = this; 给我这个错误...

E0144 “Value::Array *”类型的值不能用于初始化“Value::Array *”类型的实体。

最佳答案

可以在更简单的代码中看到问题

enum SPELLSTATUS { NEW, FAIL, OK } spellStatus = SPELLSTATUS::NEW;

enum SPELLSTATUS { NEW, FAIL, OK } spellStatus = NEW;

E0144 a value of type "SPELLSTATUS" cannot be used to initialize an entity of type "SPELLSTATUS" NcEdit D:\Systems\Editor2019\Spell.cpp 30

VS2019.

编译和运行都很好。

关于c++ - X 类型的值不能用于初始化 X 类型的实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51355887/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com