compilation error C++ : can not call member function without object -


i have following main file tried create map predefined value , pass further processing other method. main file shown below :

int main(){   map<id,porto> _portoinit;    id = 1;    porto p;   p.val = 5;    _portoinit.insert(pair<id, porto>(id, p));    porto::setporto(_portoinit);    return 1; } 

where setporto defined under class following (in seperate file)

void porto::setporto( const map<id,porto>&  _portoblock ) {    //do stuffs }; 

i got prompted error of "error: cannot call member function ... without object" did not declare object of _portoinit in main file or wrong way of declaration?

you need invoke method through actual object:

p.setporto(_portoinit); 

unless setporto static method, code invalid.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -