ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
What will happen if when say delete this ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What will happen if when say delete this ?
Answer
# 1
delete "this" lead in calling the destructor twice.
"this" poanter is related to object and the destructor is 
called when the object goes out of scope.
 
Is This Answer Correct ?    1 Yes 1 No
Dee
 
  Re: What will happen if when say delete this ?
Answer
# 2
delete this will call the destructor, but should not be 
called in the destructor but in any other member function.
 
Is This Answer Correct ?    1 Yes 0 No
Hidden Prairie
 
 
 
  Re: What will happen if when say delete this ?
Answer
# 3
There are two scenarios:

1. Using "delete this;" in destructor

Here the call will be a recursive call to the destructor 
infinitely. So the program hangs here.

2. Using "delete this;" in other members of a class 
including constructor.

In this case, the call is a sucide call since the object 
tries to delete itself which is nothing but sitting in a 
space and destroy that space itself. That is definitely a 
memory crash.
 
Is This Answer Correct ?    0 Yes 1 No
Mms Zubeir
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
What is a constructor initializer list and when we use constructor initializer list? TCS2
class Foo { int x; public: Foo(int I); }; If a class does not have a copy constructor explicitly defined one will be implicitly defined for it. Referring to the sample code above, which one of the following declarations is the implicitly created copy constructor? a) Foo(Foo *f); b) Foo(Foo &f); c) Foo(const Foo *f); d) Foo(const Foo &f); e) Foo(int); Quark3
What are the basics of classifying different storage types, why? Symphony1
How to write Multithreaded applications using C++? Honeywell1
How many bit combinations are there in a byte? Intel7
class Foo { const int x; protected: Foo(int f); ~Foo(); }; Foo f; Referring to the sample code above, why will the class declaration not compile? a) The variable x is const. b) The destructor is protected. c) The destructor is not public. d) The constructor is protected. e) There is no default constructor. Quark4
What are the advantages and disadvantages of using inline and const? TCS1
In C++ cout is: a) object b) class c) something else Lehman-Brothers10
What is Memory Alignment? TCS1
what is data Abstraction? and give example TCS13
Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }  2
what is meaning of isa and hsa  1
class HasStatic { static int I; }; Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration? a) HasStatic I = 10; b) int static I = 10; c) static I(10); d) static I = 10; e) int HasStatic::I = 10; Quark1
Explain working of printf?  3
what is the behaviour of C and C++ compiler for the below statements. int *p; p = malloc(100); Is the behaviour same ? or different ?  1
When volatile can be used? Symphony2
Explain the difference between 'operator new' and the 'new' operator? Lucent1
How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)  2
What is the output of printf("%d")? HCL25
is throwing exception from a constructor not a good practice ? Ericsson4
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com