Class Quiz-Asked in Interviews

How can we make a C++ class such that objects of it can only be created using a new operator? If a user tries to create an object directly, the program produces a compiler error.

A) Not Possible

B) By making destructor private

C) By making constructor private

D) By making both constructor and destructor private

Solution:

B) is Correct

This code snippet explains the solution

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

--

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

DeFi Insurance Design: Always Start from General Equilibrium to Reduce Systematic Arbitrage

Boundary Traversal

フルバージョンを見る るろうに剣心:決勝(1970)  フルHD「オンライン無料

Best Dragon Naturally Speaking Support For SBAC

RaspberryPi: IP address LCD display

A UI for everyone, Unity makes it easy!

AWS EC2 Plugin for Jenkins for jobs requiring higher capacity machine

Migrate EC2 Instance from one region to other

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Placewit

Placewit

Upskilling students for tech placements!

More from Medium

Path With Minimum Effort

One Mile on the globe Puzzle

LeetCode 238 — Product of Array Except Self

Maximum Points You Can Obtain from Cards — LeetCode