C ++: Сравнение указателей базового и производного классов

Мне нужна информация о передовых методах сравнения указателей в таких случаях, как этот:

class Base {
};

class Derived
    : public Base {
};

Derived* d = new Derived;
Base* b = dynamic_cast<Base*>(d);

// When comparing the two pointers should I cast them
// to the same type or does it not even matter?
bool theSame = b == d;
// Or, bool theSame = dynamic_cast<Derived*>(b) == d?
10
задан Paul Manta 14 April 2011 в 11:47
поделиться