47 lines
413 B
C++
47 lines
413 B
C++
// testTemplate.cpp : Defines the entry point for the console application.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
class a
|
|
{
|
|
public:
|
|
|
|
template < void (a::*f)( void ) >
|
|
void g()
|
|
{
|
|
(this->*f)();
|
|
}
|
|
|
|
void f1()
|
|
{
|
|
puts( "a::f1()" );
|
|
}
|
|
|
|
void f2()
|
|
{
|
|
puts( "a::f2()" );
|
|
}
|
|
|
|
void g1()
|
|
{
|
|
g<&a::f1>();
|
|
}
|
|
|
|
void g2()
|
|
{
|
|
g<&a::f2>();
|
|
}
|
|
};
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
a o;
|
|
|
|
o.g1();
|
|
o.g2();
|
|
|
|
return 0;
|
|
}
|
|
|