last changes from bloomberg.
This commit is contained in:
64
cpp/hidden_method_call.cpp
Normal file
64
cpp/hidden_method_call.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Check cf5-opt.vim defs.
|
||||
VIM: let g:lcppflags="-D__USE_XOPEN2K8 -O2 -pthread"
|
||||
VIM-: let g:lcppflags="-std=c++11 -O2 -pthread"
|
||||
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||
VIM-: let g:cf5output=0
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
struct A
|
||||
{
|
||||
A()
|
||||
{}
|
||||
~A()
|
||||
{}
|
||||
|
||||
virtual void fun()
|
||||
{
|
||||
std::cout << "I am a hidden function." << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
struct B : public A
|
||||
{
|
||||
B()
|
||||
{}
|
||||
~B()
|
||||
{}
|
||||
|
||||
void fun()
|
||||
{
|
||||
std::cout << "I am the visible function." << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main ( void )
|
||||
{try{
|
||||
|
||||
B o;
|
||||
|
||||
o.fun();
|
||||
|
||||
o.A::fun();
|
||||
|
||||
typedef A a_type;
|
||||
o.a_type::fun();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch ( const std::exception& e )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "unknown exception." << std::endl;
|
||||
return 1;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user