我希望这段代码能够打印'Same 1' 和 'Same2',但它只打印'Same1':
#include <iostream>
#include <typeinfo>
using namespace std;
struct C{virtual ~C(){}};
struct D : C{};
int main(){
D d;
C c, &cr1 = d;
if(typeid(cr1) == typeid(D)) cout << "Same1";
if(typeid(&cr1) == typeid(D*)) cout << "Same2";
}
Run Code Online (Sandbox Code Playgroud)
§5.2.8/ 2和§5.3.1/ 3似乎都向我建议应该打印'Same2'.
捕获的内容和位置是什么?