#include "string.h"
struct Irregular{
std::string present;
std::string simplepast;
std::string pastparticiple;
}
union Verbform{
Irregular* irregular;
std::string* regular;
Verbform(Irregular irreg){irregular=new Irregular(irreg);}
Verbform(std::string s){regular=new std::string(s);
~Verbbform(){delete regular;} //here is my problem
}
class Verb{
public:
//some public functions
private:
Verbform verbform;
//some other things;
}
[当我这样做并以不规则动词对其进行初始化时,他会删除完整的不规则动词还是仅删除第一个字符串?
[当我这样做:~Verbform(){delete irregular;}
并用普通字符串初始化它时,他删除的内容是否超过我要他删除的内容?
我正在编写翻译,为此,我想创建一个Verb类。此类仅应在不规则的情况下保存完整的查询,因为它会产生较大的列表,占用大量...
delete irregular
调用~Irregular()
析构函数,然后调用3次std::string::~string()
析构函数。当irregular
为n而不是活动的联合成员时,调用此方法为undefined behavior