Getting a vector into a function that expects a vector<Base*>

后端 未结 9 1861
日久生厌
日久生厌 2020-11-29 07:11

Consider these classes.

class Base
{
   ...
};

class Derived : public Base
{
   ...
};

this function

void BaseFoo( std::ve         


        
9条回答
  •  日久生厌
    2020-11-29 07:58

    If you dealing with a third-party library, and this is your only hope, then you can do this:

    BaseFoo (*reinterpret_cast *>(&derived));
    

    Otherwise fix your code with one of the other suggesstions.

提交回复
热议问题