singleton pattern really necessary?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was wondering, if a person wants there to be only one instance of a class, they can simply do something like:

class {
<class definition here>
} classInstance ;

which automatically creates a single instance of a class. Why go to the extent of locking the constructor, copy constructor, operator= etc? The only possible thing (that I can think of) that cannot be done is conveniently passing it as an argument to a function. Is there any other reason that would make a class-name necessary?

Shriramana Sharma.

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux