mercredi 23 avril 2014

c ++ - pouvez-vous appeler une méthode protégée à l'intérieur d'un écrasement privé virtuel ? -Débordement de pile


I having a link error (unresolved external symbol) for a protected method (not virtual) being called in a virtual private method that Im overwriting. The link error is solved by changing protected to public...??? I didnt found any info on that.. Things goes like this:


class Base{

protected:
void Finish();

private:
virtual void VOnUpdate()=0;

};
class Derived: public Base{

private:
virtual void VOnUpdate(){

Finish();// unresolved Finish() being called

}

};

With some tests I did I concluded that the problem is also solved if I define Finish() on the header file (where Base is declared). But I dont want nor can do that, as Finish needs a include that includes Base (would cause circular reference). But note this circular thing is not the problem, I created a dummy method just to confirm, it also creates the link error. Im clueless.



I having a link error (unresolved external symbol) for a protected method (not virtual) being called in a virtual private method that Im overwriting. The link error is solved by changing protected to public...??? I didnt found any info on that.. Things goes like this:


class Base{

protected:
void Finish();

private:
virtual void VOnUpdate()=0;

};
class Derived: public Base{

private:
virtual void VOnUpdate(){

Finish();// unresolved Finish() being called

}

};

With some tests I did I concluded that the problem is also solved if I define Finish() on the header file (where Base is declared). But I dont want nor can do that, as Finish needs a include that includes Base (would cause circular reference). But note this circular thing is not the problem, I created a dummy method just to confirm, it also creates the link error. Im clueless.


0 commentaires:

Enregistrer un commentaire