運算符重載機制(下篇)

1 大型對象 咱們將Complex的運算符都定義爲以類型Complex爲參數,對於Complex運算符,各個運算對象都須要複製。然而對於大型對象來講,複製時的開銷是很恐怖的,因此爲了不過分複製,咱們有兩個解決辦法: 1 定義以引用爲參數的函數。 例如: class Matrix{ public: friend Matrix operator(const Matrix &,const M
相關文章
相關標籤/搜索