C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 47)
47.
What will happen if a class is not having any name?
It cannot have a destructor.
It cannot have a constructor.
It is not allowed.
Both A and B.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
25 comments Page 3 of 3.

Nikhil said:   7 years ago
Can I do this for java too?

How can I do it for the class which contains main function.

Salvin kajar said:   7 years ago
As per my knowledge, if a class is not having a name then it's an anonymous class and anonymous class can not have a constructor but it can have a destructor.
(2)

Sravani Gudimetla said:   6 years ago
@Jathin:

In Rahul's code , instead of "#include<iostream.h>" you add "#include<iostream>"
Then you won't get any error.

Harsh said:   6 years ago
If the constructor is not made by the user then the complier automatically makes default constructor. Answer is. It connot has destructor.

Navya said:   5 years ago
It can have a destructor for the deallocation of memory, but the constructor cannot be allocated.
(1)


Post your comments here:

Your comments will be displayed after verification.