Can we declare destructor as static? Explain?

Answers were Sorted based on User's Feedback



Can we declare destructor as static? Explain?..

Answer / murali

Yes we can. But you can't use it.

Use new to create the object.
At the same time you can't use delete.

Why can't : As destuctor uses 'this' context and in this
case it can't being static.

Is This Answer Correct ?    8 Yes 2 No

Can we declare destructor as static? Explain?..

Answer / jaroosh

To sum up : you CANT declare destructor as static, as you
CANT declare constructor as static, both are responsible for
destroying and creating OBJECTS while static storage means
that methods/members do not belong to any objects but to the
whole class.

Is This Answer Correct ?    7 Yes 1 No

Can we declare destructor as static? Explain?..

Answer / sunil

declaring destructor and constructor as static is a syntax error

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ General Interview Questions

What are the differences between public, private, and protected access?

12 Answers   IBM, Oracle, Wipro,


There is a array of 99 cells and we have to enter 1-100 elements in it , no two elements would repeat , so the is one no. missing because 99 cells and 1-100 nos. so we had to implement a function to find that missing no.

2 Answers   Nagarro,


What is a terminating character in c++?

0 Answers  


Can I learn c++ in a week?

0 Answers  


What is a class template?

0 Answers  






Is c++ used anymore?

0 Answers  


What is string in c++ programming?

0 Answers  


What is setf in c++?

0 Answers  


Explain the uses of static class data?

0 Answers  


Difference between inline functions and macros?

0 Answers  


In java a final class is a class that cannot be derived. How can you make a similar class in C++

1 Answers  


How much maximum can you allocate in a single call to malloc()?

0 Answers  


Categories