c++ - Why is my function "missing argument lists"? -
i'm not sure i've done wrong in project. have 2 files, airports.h header file , main source file. in main source file have
string code,name; int deptax, conntime; cin >> code >> name >> deptax >> conntime; airport myairport(code,name,deptax,conntime); cout << myairport.getcode << endl;
and in airports.h header file have
class airport{ public: airport(string code, string name, int departuretax, int connectiontime) :code(code), name(name), departuretax(departuretax), connectiontime(connectiontime) {...} string getcode(){ return code; }//then getname, getdeptax, getconntime... }
when run main source file, error "error c3867: 'airport::getcode': function call missing argument list; use '&airport::getcode' create pointer member" in line 5 there.
i'm beginner i'm not sure why it's telling me this. shouldn't .getcode() work how it's written? when looked previous solutions online, solution unrelated "pointer member" error, think may using c++ in way it's not meant used.
cout << myairport.getcode() << endl;
note parenthesis needed call function. reason requiring () there function named without them has valid meaning , quite different calling function.
Comments
Post a Comment