dimanche 12 mars 2017

Constness of version method when it gets called by another method in the same class

I know that when there are both const and non-const versions of a method with the same name and parameters, the version chosen is determined by the const-ness of *this. (constness of the method is part of the signature right?)

But what happens when its being called by another method?

An example

class a{
   void b() const{
      c();
      //do fantastic things
   }
   const_iterator c() const;
   iterator c();
};

When I call b() from a nonconst instance of a, how I know which version of c() gets invoked?

Aucun commentaire:

Enregistrer un commentaire