📄 cpp02.cpp
字号:
// Coded by plusir -- Jan.14.2003.
// Standard C++ Bible -- (P742-27-2)
#include <iostream>
#include <typeinfo>
using namespace std ;
class Control
{
public:
virtual void foo( void ) const { }
} ;
class TextBox : public Control { } ;
class EditBox : public TextBox { } ;
class Button : public Control { } ;
void paint( Control & ) ;
int main()
{
Control ct ;
paint( ct ) ;
Button bt ;
paint( bt ) ;
TextBox tb ;
paint( tb ) ;
EditBox eb ;
paint( eb ) ;
return 0 ;
}
void paint( Control &cr )
{
try {
TextBox& ctl = dynamic_cast<TextBox&>( cr ) ;
cout << "Paint a TextBox" << endl ;
}
catch ( bad_cast ) {
cout << "nonTextBox, can't paint" << endl ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -