Answers

Question and Answer:

  Home  Programming Concepts

⟩ Explain how to write a class in c++ using only one object?

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.

 178 views

More Questions for you: