- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我遇到了以下规则 N4296::12.7/4 [class.cdtor]
:
If the virtual function call uses an explicit class member access (5.2.5) and the object expression refers to the complete object of x or one of that object’s base class subobjects but not x or one of its base class subobjects, the behavior is undefined.
这是什么意思?你不能举例说明一下吗?对我来说有点难以想象。
最佳答案
如果你还想知道,这是指当你在一个基类的析构函数中,你指的是整个对象已经被销毁的东西。一个例子:
struct Derived;
struct Base {
Derived &der;
Base(Derived &d): der(d) {}
~Base();
};
struct Derived: Base {
int value;
Derived(): Base(*this) {}
};
#include <iostream>
Base::~Base() {
std::cout <<
der.value // this is the undefined behavior! der.value is *gone*
<< std::endl;
}
AFAIK,除了在 Base
的析构函数中访问 der.value
之外,该代码中的所有内容都是合法的,因为当您销毁 Base
时,您您已经销毁了您在 der
Derived
关于c++ - 通过成员访问表达式调用虚函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30882420/
我有一个特别的问题想要解决,我不确定是否可行,因为我找不到任何信息或正在完成的示例。基本上,我有: class ParentObject {}; class DerivedObject : publi
在我们的项目中,我们配置了虚 URL,以便用户可以在地址栏中输入虚 URL,这会将他们重定向到原始 URL。 例如: 如果用户输入'http://www.abc.com/partner ',它会将它们
我是一名优秀的程序员,十分优秀!