Hello all,
I'm having a bit of trouble with this program I'm working on. I have a base class, we'll call it Base, and two nearly identical Derived classes, only one of which is relevant. I created a pointer (Base *BP), and pointed it to Derived &DO. I need to downcast it so that it can access the Derived class's member functions (or, rather, just one, called setType(string), but that's the idea). I spent hours troubleshooing and researching casting, but can't quite figure out what's wrong. Any help would be appreciated.

Here's basically what it looks like:

Base *BP;

BP = new Derived();
Derived *DO = dynamic_cast<Derived *>(BP);


BP->setType("hello");

This results in getting a "error: class Base has no member named setType"


Thank you for your time.

Shouldn't you rather be calling the setType() through the DO pointer instead of BP (assuming that the Base class does not and is not intended to have a setType() method), i.e.
DO->setType("hello");
should work.