Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

C++ programming practical question 8

  Shared By: Adah Miller    Date: Jan 24    Category: C++ Programming    Views: 82

Answer:

class some{
public:
~some()
{
cout<<"some's destructor"<<endl;
}
};

void main()
{
some s;
s.~some();
}


Answer:
some's destructor
some's destructor


Explanation:
Destructors can be called explicitly. Here 's.~some()' explicitly calls the
destructor of 's'. When main() returns, destructor of s is called again,
hence the result.

Share: 
 

Didn't find what you were looking for? Find more on C++ programming practical question 8 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: