Private static

G

Gaurav Jain

Hi Gurus,

Can somebody tell me a scenario where the static data should be made
private.

Regards,
GJ
 
J

James Daughtry

Reference counting. You still need a class level variable, but the
outside shouldn't be able to access it.
 
K

Kristo

Gaurav said:
Hi Gurus,

Can somebody tell me a scenario where the static data should be made
private.

The Monostate Pattern - all instances of a class share the same state.
A private static member variable is perfect for that.

Kristo
 

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

Similar Threads


Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top