我试图理解我们在C++程序中通常面临的错误的含义.
在编译程序时我遇到了错误(我故意做了这个错误,请不要告诉它如何纠正)并且有一个注释,它是:
note: no known conversion for argument 1 from ‘int’ to ‘const account&’
我想了解本说明的含义.
我的计划是:
#includeclass account { private: int a_no; public: account() { a_no = 0; } void showData() { std::cout<<"\n account number = "< 我知道我没有定义一个可以接受一个参数的构造函数,这样做会删除我的错误.
好的,在编译时我得到了:
file1.cpp: In function ‘int main()’: file1.cpp:20:17: error: no matching function for call to ‘account::account(int)’ account a2(2); ^ file1.cpp:20:17: note: candidates are: file1.cpp:7:9: note: account::account() account() ^ file1.cpp:7:9: note: candidate expects 0 arguments, 1 provided file1.cpp:2:7: note: account::account(const account&) class account ^ file1.cpp:2:7: note: no known conversion for argument 1 from ‘int’ to ‘const account&’我想知道最后一行的含义是什么
file1.cpp:2:7: note: no known conversion for argument 1 from ‘int’ to ‘const account&’
?