🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Sockets

Started by
12 comments, last by Gyzmo 23 years, 10 months ago
I use it to create a Singleton object, a Signleton is a Design Pattern which allows you to control the creation of a class, an example: (stolen)

    class Singleton{  static Singleton s;  int i;  Singleton(int x) : i(x) { }  void operator=(Singleton&);  Singleton(const Singleton&);public:  static Singleton& getHandle()  {    return s;  }  int getValue() { return i }  void setValue(int x) { i = x }};Singleton Singleton::s(47);int main(){  Singleton& s = Singleton::getHandle();  cout << s.getValue() << endl;  Singleton& s2 = Singleton::getHandle();  s2.setValue(9);  cout << s.getValue() << endl;}    


This example (shamelessly stolen from Bruce Eckel''s Book ''Thinking in C++ 2nd Edition Volume 2) creates a class that can be not be instantiated by the user, the user (read client programmer) can however request a handle from the object. For a better explanation read Bruce Eckels book (follow the link above) it is downloadable in pdf format.

(Testing new sig)



Gyzmo
=======================
Meddle not in the affairs of dragons for you are crunchy and go well with toast.
Gyzmo=============================="Well is the world standard" - The Alchemist"Not in Canada!" - jonnyfish
Advertisement
Well, in that case... doesn''t the user (client programmer) still need access to the header file with the class definition? And if so, he/she can still just move the contructor to ''public'' and the whole idea sort of disappears?


Anyway, I''ve never used #pragma directives when programming for Linux, but in MSVC++ you do it like

#pragma warning( disable: 42 763 )

which will disable warning messages 42 and 763.
-------------------------------------------------------------LGPL 3D engine - http://www.sourceforge.net/projects/realityengine
man gcc

look for the -W switch

http://www.thisisnurgle.org.uk

"Nazrix is cool" Nazrix first, then Darkmage, then Nazrix again

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

I already looked there and couldn''t find any argument disabling this specific warning....

Thanks anyway.



Gyzmo
=======================
Meddle not in the affairs of dragons for you are crunchy and go well with toast.
Gyzmo=============================="Well is the world standard" - The Alchemist"Not in Canada!" - jonnyfish

This topic is closed to new replies.

Advertisement