I am trying to understand the meaning of the errors that we usually encounter in C ++ programs.
When compiling the program, I got an error (I made this error intentionally, please do not say how to fix it), and there is a note there, which is:
note: no known conversion for argument 1 from 'int' to 'const account&'
I want to understand the meaning of this note.
My program:
#include<iostream> class account { private: int a_no; public: account() { a_no = 0; } void showData() { std::cout<<"\n account number = "<<a_no<<std::endl; } }; int main() { account a1; a1.showData(); account a2(2); a2.showData(); return 0; }
I know that I have not defined a constructor that can take one argument, and that will make my mistake.
Well, compiling this, I got:
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&'
I want to know what the last line of file1.cpp:2:7: note: no known conversion for argument 1 from 'int' to 'const account&' means file1.cpp:2:7: note: no known conversion for argument 1 from 'int' to 'const account&' ?
user5112302
source share