1. RTTI ¶
λμ μΌλ‘ λ§λ€μ΄μ§ λ³μμ νμ
μ λΉκ΅νκ³ , νΉμ νμ
μΌλ‘ μμ±νλ κ²μ κ°λ₯νκ² νλ€. (μλ°μμλ instanceofλ₯Ό μκ°ν΄λ³΄λ©΄ λ λ―)
MFCμμλ C++μμ νμ€μΌλ‘ μ΄μ©λκΈ° μ΄μ λΆν° λ§€ν¬λ‘λ₯Ό μ΄μ©ν λ°©λ²μΌλ‘ μ΄κ²μ μ§μνμΌλ©°, μμ§λ κ·Έ μμ¬κ° λ¨μμλ€.
2. example ¶
μλλ RTTIμ μ°μμλ₯Ό ννν μΌμμ΄λ€.
μμμ 보λ―μ΄ ν΄λμ€μ νμ λΉκ΅νλ κ²μ΄ κ°λ₯νλ€.
~cpp
class base {
};
class derived : public base {
int compare(derived &ref);
};
int my_comparison_method_for_generic_sort(base &ref1, base &ref2)
{
derived d = dynamic_cast<derived &>(ref1); // rtti used here
// rtti enables the process to throw a bad_cast exception
// if the cast is not successful
return d.compare(dynamic_cast<derived &>(ref2));
}









