Jump to content

problema com função


Recommended Posts

void Central :: removeObjectoConsumidor(int id) 
  for(vector<Consumidor*>::iterator it = consumidor.begin();it !=consumidor.end(); it++) 

Boa tarde,estou com uns problemas relativos a esta funçao quero que receba um inteiro e o pesquise dentro do vector e depois o apague quando compilo isto da sempre erro.

entral.cpp: In member function ‘void Central::removeObjectoConsumidor(int)’:central.cpp:17: error: request for member ‘getId’ in ‘it.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Consumidor**, _Container = std::vector<Consumidor*, std::allocator<Consumidor*> >]()’, which is of non-class type ‘Consumidor*’

central.cpp: At global scope:                                                                                                                                 

central.cpp:31: error: prototype for ‘void Central::removeObjectoRenovaveis(Renovaveis*)’ does not match any in class ‘Central’                               

central.h:41: error: candidate is: void Central::removeObjectoRenovaveis(int)                                                                                 

central.cpp:46: error: prototype for ‘void Central::removeObjectoNaoRenovaveis(NaoRenovaveis*)’ does not match any in class ‘Central’                         

central.h:44: error: candidate is: void Central::removeObjectoNaoRenovaveis(int)                                                                             

make: ** [central.o] Erro 1                                                                             

Link to comment
Share on other sites

Assim numa vista na diagonal, (*it) é um apontador para Consumidor, logo não podes aceder ao método com o .  mas sim com -> ou desreferenciar

"What we do for ourselves dies with us. What we do for others and the world, remains and is immortal.", Albert Pine

Blog pessoal : contém alguns puzzles, algoritmos e problemas para se resolver com programação.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.