How to write a class in c++ using only one object?

Showing Answers 1 - 2 of 2 Answers

priyadarshani

  • Jun 22nd, 2006
 

class singleten{ static int count; singleten() { if (count==1) { exit(0); } count++; }}singleten::count =0;void main(){singleten s1;singleten s2;}program is terminated as soon as second object is created.

  Was this answer useful?  Yes

kalayama

  • Dec 8th, 2006
 

Was that answer to the question.The question was "Writ a class using one object". Doesn't mean that the the class can have only one object ain't it?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions