如果类型不是“完全定义的”,我是否正确阅读了标准,5.2.8.3: ... If the type of the
expression is a class type, the class shall be completely-defined.
这是否意味着以下程序未定义?
foo.cpp:
struct foo
{
virtual void a(){}
};
struct bar : foo
{
virtual void a(){}
};
bar abar;
foo& get_some_foo()
{
return abar;
}
主.cpp:
#include <iostream>
#include <typeinfo>
struct foo;
foo& get_some_foo();
int main()
{
foo& a_ref_foo(get_some_foo());
std::cout << "a_ref_foo typeid name: " << typeid(a_ref_foo).name() << std::endl;
return 0;
}
MSVC10 输出:`a_ref_foo typeid name: struct foo'