473,413 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Dangling object and how to solve it

explain about Dangling object and how to solve it..
show some code about it..
thank tou
Sep 8 '07 #1
2 2783
JosAH
11,448 Expert 8TB
explain about Dangling object and how to solve it..
show some code about it..
thank tou
Expand|Select|Wrap|Line Numbers
  1. Foo* p= new Foo();
  2. delete p;
  3. // now p is dangling, i.e. it points into lala-land
  4.  
kind regards,

Jos
Sep 8 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
You avoid this situation by not using pointers directly. Instead you use a smart pointer which is a type of Handle class. There is an article about this in the C/C++ Articles forum complete with code samples.
Sep 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Aravind | last post by:
I would like to know in what manner dangling pointers affect the security of a application developed using C++.What are the loopholes that are created by dangling pointers and how they could be...
11
by: John | last post by:
Hi: Below is a simple code: class link1 { public: link1(); link1(int &b1, double &b2); int* a1;
6
by: Tony Johansson | last post by:
Hello Experts! I'm reading in a book about C++ and the book says common errors is "A function should not return a constant references to its parameter passed by constant references" Why? Here...
6
by: Matthias Kaeppler | last post by:
Hi, I have a question regarding references, and their chance to "dangle" (if that's possible at all): Say I have a collection ob objects, and I take a reference to one of them. Now I sort...
20
by: __PPS__ | last post by:
Hello everybody in a quiz I had a question about dangling pointer: "What a dangling pointer is and the danger of using it" My answer was: "dangling pointer is a pointer that points to some...
1
by: sekhar_ps | last post by:
if we store some value at the place in memory which void pointer references then we increment void pointer this leads to dangling pointer?can any one explain whats the reasons for dangling pointer
10
by: Belebele | last post by:
Suppose that I have a method that returns references to "elements" in an iterator, and a method to advance the iterator: class Element { /* ... */ }; class Iterator { public: Element&...
5
by: madhusagar79 | last post by:
I got one issue to find the Dangling Pointer. Is there any way to find the Dangling Pointer?
1
by: sridhard2406 | last post by:
Hi All, I have a doubt on undrestanding Dangling pointers.Below I mentioned sample code. please let me know, my view on Dangling pointers is correct or not? main( ) ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.