I can’t find the answer anywhere. It can be done by using condition and throwing exception but is there any other way to do so?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It isn’t clear why you would want a class that cannot be constructed under any circumstances, but you could make all constructors
privateand provide no implementation for them. This will prevent construction at compile time.In C++11 you can use
deletefor all the constructors: