class A { ... union { int a; int b; }; }; class B : public A { ... int c; //<- Can this use the same storage as the union? };
一个更具体的例子是标记联合的想法,你希望有一个子类为联合添加一个类型.
解决方法 你说,I’m wondering if it’s possible to append members to a C++ union in a subclass.
该语言不允许扩展联合.无法将成员附加到工会.
更糟糕的是,与可以通过创建子类(结构)扩展的类和结构不同,联合不能具有基类.它们也可能不被用作基类.
总结以上是内存溢出为你收集整理的c – 覆盖超类联合的子类联合ontop全部内容,希望文章能够帮你解决c – 覆盖超类联合的子类联合ontop所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)