By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

calling base class function only once

P: n/a
Hi,

Consider the following class hierarchy:

A
B C D

a has a fcuntion func() which needs to be called only once during
application lifetime.

B b;
b.func();
.......

later

C c;
c.func(); //should nt get called or executed.

How can this be done?

One way is to use a mutex and initialize the first time func is called.

Is there any other way?Some design pattern?

Regards,
Furqan


Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* Furqan:
Hi,

Consider the following class hierarchy:

A
B C D

a has a fcuntion func() which needs to be called only once during
application lifetime.


Do it in the Z constructor and make Z a singleton.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.