Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > как включить RTTI


Автор: boriska 15.7.2007, 12:08
Есть код :
Код

class Base
{
public:
    virtual ~Base(){}
};

class Derived : public Base
{
public:
    virtual ~Derived(){}
};

int main(int argc, _TCHAR *argv[])
{
    Base *b = new Derived;
    Derived *d;
    if(d = dynamic_cast<Derived *> (b))
            cout << "ok" << endl;
    else
            cout << "trable" << endl;

    return 0;
}


На Dev-C++ все нормально, но
при компиляции в VS.NET 2002 программа вылетает: "This application has requested the Runtime to terminate it in an unusual way..."
Я так полагаю, что дело в настройках студии, но сам не нашел smile 

Автор: zkv 15.7.2007, 15:24
вот для 2003 студии:
Цитата(MSDN)

/GR
This option (/GR) adds code to check object types at run time. When this option is specified, the compiler defines the _CPPRTTI preprocessor macro. The option is cleared (/GR–) by default.

For more information on run-time type checking, see Run-Time Type Information in the C++ Language Reference.

To set this compiler option in the Visual Studio development environment 

Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties. 
Click the C/C++ folder. 
Click the Language property page. 
Modify the Enable Run-Time Type Info property. 
To set this compiler option programmatically

See RuntimeTypeInfo Property.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)