what's the design pattern of following codes?

A

Alien

The class TimerScheduler inherits from a template which uses the
parameter TimerScheduler itself.
What's the benefit of this arrangement?
Thanks.

00028 class TimerScheduler : public TCountedObject<TimerScheduler>
00029 {
00031 TimerSchedulerImpl* pimpl_;
00032 public:
00034 TimerScheduler();
00035
00037 ~TimerScheduler();
00038
00056 Timer* schedule(Functor const& functor, Queue* queue, Time
t)
00058
00062 void cancel(Timer* timer);
00063 };
 
V

Victor Bazarov

Alien said:
The class TimerScheduler inherits from a template which uses the
parameter TimerScheduler itself.
What's the benefit of this arrangement?

Find the online resources on "Curiously Recursive Template Pattern"
and read about it. Even Wikipedia has an article on it.
Thanks.

00028 class TimerScheduler : public TCountedObject<TimerScheduler>
00029 {
00031 TimerSchedulerImpl* pimpl_;
00032 public:
00034 TimerScheduler();
00035
00037 ~TimerScheduler();
00038
00056 Timer* schedule(Functor const& functor, Queue* queue, Time
t)
00058
00062 void cancel(Timer* timer);
00063 };

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top