Singleton Class
Learn to create a singleton class in the C++ language.
We'll cover the following
Challenge
Write a program to create a Sample
class as a Singleton class. A Singleton class is a class from which only one object can be created.
Sample run
If you correctly do the coding exercise and don’t change anything in the main( )
function, then you should expect to see the following console output:
0x20014c70
0x20014c70
0x20014c70
Coding exercise
Try to solve this challenge on your own. If you can’t solve it, you can look at the solution and explanation below.
Get hands-on with 1400+ tech skills courses.