c++ error no instance of constructor -
i'm new c++ , trying homecoming values passed through constructor, not sure have done wrong on below code keeps giving me error: no instance of constructor..matches
, cannot convert parameter 3 'const char [5]' 'int'
#include <iostream> #include <string> using namespace std; class testclass{ string a; string b; int x; public: testclass(string m, string n, int y){ this->a = m; this->b = n; this->x = y; } int test(){ homecoming this->x; } }; int main(){ testclass *a = new testclass("test1","test2","9999"); cout<<a->test()<<endl; }
you passing number 9999 "9999"
-- quotes around denote string. pass 9999
.
c++
No comments:
Post a Comment