What is your reaction to following line of code? , C/C++ Programming

Q-What is your reaction to following line of code?

              delete this;

A: This is not a good programming Practice. A good programmer will insist that you must absolutely never employ the statement if the class is to be utilized by other programmer's instantiated as extern, static or automatic objects. That much must be obvious. The code contains two built-in pitfalls. First one, if it executes in a member function for an static, extern or automatic object, the program will perhaps crash immediately the delete statement executes. There is no portable method for an object to tell that it was instantiated on the heap, thus the class cannot assert that its object is correctly instantiated. Second one, while an

 

Posted Date: 3/20/2013 8:19:36 AM | Location : United States







Related Discussions:- What is your reaction to following line of code? , Assignment Help, Ask Question on What is your reaction to following line of code? , Get Answer, Expert's Help, What is your reaction to following line of code? Discussions

Write discussion on What is your reaction to following line of code?
Your posts are moderated
Related Questions
c program to construct a structure: struct sensus                 {                                 char name[30];                                 long int population;

Q: But MFC appear to encourage the employ of catch-by-pointer; should I do the similar? A: Depends. If you're utilizing MFC and catching one of their exceptions, by all means, d

Is it legal for a member function to say delete this? A: As long as you're cautious, it's OK for an object to delete this. Here's how I define "cautious": You have to be a

C Program for Palindrome Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4


Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Define a structure in C++: Write a program a structure in c++ program. void main() {                 struct player                 {                 char name[2

Define global variable in c++ program: How to define a global variable and need of global variable in c++ program. int main() {    int m=20;    clrscr();    for

#include using namespace std; void print(int marks_arr[],int cnt) { int ind[cnt]; int i=0; int j=0; int k=0; int s=0; for(k=0;k { ind[k]=0; } int cnt1=0; for(i=0;i

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b