编译器如何知道如何正确处理这段代码?
struct Foo
{
int bar;
Foo()
{
bar = 3;
}
Foo& operator=(const Foo& other)
{
bar = other.bar;
return *this;
}
int SetBar(int newBar)
{
return bar = newBar;
}
};
static Foo baz;
static Foo someOtherBaz = baz;
static int placeholder = baz.SetBar(4);
someOtherBaz.bar
的最终值将是什么?
TYPE t = arg
和TYPE t(arg)
是相同的。 - R Samuel Klatchkoextern Foo f1; Foo f2 = f1;
,则可以从f1的原始未初始化内存初始化f2。 - R Samuel Klatchko