2

Possible Duplicate:
Regular cast vs. static_cast vs. dynamic_cast

is there any harm in using static_cast when I know the type for sure? Any issue if it has virtual functions?

class Base {
public:
    virtual void foo();
};

class Derived1 {
public:
    virtual void foo();
    void bar();
};


Base* b1 = new Derived1();
Derived1* d1 = static_cast<Derived1*>b1;
d1->bar();
Community
  • 1
  • 1
excalibur
  • 924
  • 2
  • 11
  • 26

0 Answers0