dimanche 27 septembre 2020

undefined symbol: typeinfo error when returning shared ptr from virtual function

ld.lld: error: undefined symbol: typeinfo for <derived classname>

Why am I getting this error for the following code?

base::getABC is never called directly. If I remove the definition of the virtual destructor I get an error about it.

class Base {
public:
 virtual const std::shared_ptr<ABC>  getABC() noexcept {
    return nullptr;
  }

  virtual ~Base() {
  }
};

class derived: public base {
 const std::shared_ptr<ABC> getABC() noexcept override {
   return abc_;
  }
};

Aucun commentaire:

Enregistrer un commentaire