Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-04-2005, 09:31 AM   #1
Beta Member
 
Join Date: Aug 2005
Posts: 1
Default Only 1 Object of the C++ class ??

Is it possible to create a class in C++ of which only 1 object can be created ?? ( Excatly 1 not more than 1 ). It should not allow more than 1 object to be created.
__________________

ZulfiqarKhan is offline   Reply With Quote
Old 08-04-2005, 10:42 AM   #2
Baseband Member
 
Join Date: Jul 2005
Posts: 55
Default

well the whole point of objects is to make multiple instances of them. If you want to write a program that only allows users to create 1 instance of an object at a time, then that has to be mediated by the program itself, not by the object class. You could always hardcode it into the main class of your program though.
__________________

Argon is offline   Reply With Quote
Old 08-04-2005, 11:38 AM   #3
Daemon Poster
 
Tulsileaf's Avatar
 
Join Date: Jul 2004
Posts: 1,249
Default Re: Only 1 Object of the C++ class ??

actually, you can make such an object by having a static boolean flag private member of the class set to false if the object has not been made and true if it has. Then just have the constructor check this flag and not create the object if it has already been made.
__________________
(|141 73g ()7 (|33|/| 11143s| |_| z1|-|7 (|43s| |/|4> |_| |-|0|1
Tulsileaf is offline   Reply With Quote
Old 08-21-2005, 07:40 PM   #4
In Runtime
 
hextcomm's Avatar
 
Join Date: Aug 2005
Posts: 237
Send a message via ICQ to hextcomm Send a message via AIM to hextcomm Send a message via MSN to hextcomm
Default Good Day

Hello, we are working on a project, we really need Programmers (all) to assist us,the primary laguages are C, C++ and C#, this project
is a free program which is to run in the background of your Operating System and
to monitor processes without hogging much system rsources and to automatically shut down suspicous processes,
if you are interested in joining as a voluntary staff member, please contact me at hextcomm@yahoo.com.

Thank You.
hextcomm is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0