Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////
- // Шаблонный Функтор c хранением состояния счетчика...
- ///
- class Display
- {
- __int64 _cnt;
- public:
- Display(){ _cnt = 0; }
- template< typename T >
- void operator()(T a)
- {
- cout << a << endl;
- _cnt++;
- }
- __int64 getCount(){ return _cnt; }
- };
- void main()
- {
- Display diFnc;
- diFnc(2);
- diFnc("myCode");
- diFnc(44.55);
- cout << "Amount of usage: " << diFnc.getCount() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement