我想了解以下行所做的:使用結構名作爲函數
BStats stats = BStats();
的結構定義如下:
struct BStats
{
unsigned a;
unsigned b;
BStats& operator+=(const BStats& rhs)
{
this->a += rhs.a;
this->b += rhs.b;
return *this;
}
};
但我沒有什麼這個想法行呢。它調用默認的構造函數嗎?
@basak你會驚訝....但是'BStats統計();'不調用任何構造函數,它甚至不聲明類型的對象'BStats'而是* *宣佈,它沒有參數,並返回一個'BStats'的功能。 Google for *最令人頭疼的解析* – 2012-03-02 01:44:30