soory~
你的代码在vc下没问题了,一切ok~
不过在codeblocks下运行,有如下错误
.cpp||In function `int main(int, char**)':|
.cpp|59|error: invalid initialization of non-const reference of type 'cpxNum&' from a temporary of type 'cpxNum'|
.cpp|14|error: in passing argument 1 of `void print(cpxNum&)'|
.cpp|62|error: invalid initialization of non-const reference of type 'cpxNum&' from a temporary of type 'cpxNum'|
.cpp|14|error: in passing argument 1 of `void print(cpxNum&)'|
.cpp|65|error: invalid initialization of non-const reference of type 'cpxNum&' from a temporary of type 'cpxNum'|
.cpp|14|error: in passing argument 1 of `void print(cpxNum&)'|
.cpp|68|error: invalid initialization of non-const reference of type 'cpxNum&' from a temporary of type 'cpxNum'|
.cpp|14|error: in passing argument 1 of `void print(cpxNum&)'|
||=== Build finished: 8 errors, 0 warnings ===|
需要把print函数需要去掉& 改为:void print(cpxNum c),就ok。
不知你用的什么环境~