class just{
public :
int x;
just(){ x=1234; }
just(int i){ x = i;}
~just(){ cout << " Here We Are\n" ;}
};
int main()
{
just j1;
just *jptr =new just(5432);
delete( jptr);
delete( &j1);
cout << "Test Out \n" ;
return 0;
}
After executing destructor for J1 program calls for an abort in Visual
Studio 6
Aug 8 '08
15 1854
tni wrote:
'new' will first call the destructor, then call 'free'.
I meant 'delete' of course.
tni wrote:
Pranav wrote:
>> Ya I know that thing, But When I call 'delete(&j1)' the destructor for 'j1' is called after this there is window appears saying 'Abort/Ignore/ Retry'. Why exactly this behaviour occurs? Can any one explain what happens during runtime?
'new' will first call the destructor, then call 'free'.
Not exactly. It will do something similar to 'free'. On some compilers, it
actually does call 'free', but that's not required by the standard.
Rolf Magnus wrote:
tni wrote:
>'delete' will first call the destructor, then call 'free'.
Not exactly. It will do something similar to 'free'. On some compilers, it
actually does call 'free', but that's not required by the standard.
He said he was using Visual C++. It does use malloc/free in new/delete.
On Aug 12, 2:08 pm, tni <nob...@example .comwrote:
Rolf Magnus wrote:
tni wrote:
'delete' will first call the destructor, then call 'free'.
Not exactly. It will do something similar to 'free'. On some compilers, it
actually does call 'free', but that's not required by the standard.
He said he was using Visual C++. It does use malloc/free in new/delete.
Recently I read from a book that free() does not call destructor for
objects properly and also for array of user defined objects. Is it
true?
Also I came through, allocator allocate an extra word of memory
specifying the size of the array from which deallocating function gets
the size of array and this word of memory usually right before the
start address returned by the allocator.
Pranav wrote:
On Aug 12, 2:08 pm, tni <nob...@example .comwrote:
>Rolf Magnus wrote:
>>tni wrote: 'delete' will first call the destructor, then call 'free'. Not exactly. It will do something similar to 'free'. On some compilers, it actually does call 'free', but that's not required by the standard.
He said he was using Visual C++. It does use malloc/free in new/delete.
Recently I read from a book that free() does not call destructor for
objects properly and also for array of user defined objects. Is it
true?
Yes, free() is just a C library function frees memory previously
allocated with one of the malloc() family of functions. It knows
nothing of C++ classes.
Operators new and delete may call malloc() and free() to allocate and
free memory, but that is only part of their jobs. The other part is
constructing and destructing the objects.
Assuming they do, operator new will call malloc to allocate memory and
then call the object's constructor. Operator delete will call the
object's destructor and then call free to release the memory.
--
Ian Collins.
On Aug 12, 3:05 pm, Ian Collins <ian-n...@hotmail.co mwrote:
Pranav wrote:
On Aug 12, 2:08 pm, tni <nob...@example .comwrote:
Rolf Magnus wrote: tni wrote: 'delete' will first call the destructor, then call 'free'. Not exactly. It will do something similar to 'free'. On some compilers, it actually does call 'free', but that's not required by the standard.
He said he was using Visual C++. It does use malloc/free in new/delete.
Recently I read from a book that free() does not call destructor for
objects properly and also for array of user defined objects. Is it
true?
Yes, free() is just a C library function frees memory previously
allocated with one of the malloc() family of functions. It knows
nothing of C++ classes.
Operators new and delete may call malloc() and free() to allocate and
free memory, but that is only part of their jobs. The other part is
constructing and destructing the objects.
Assuming they do, operator new will call malloc to allocate memory and
then call the object's constructor. Operator delete will call the
object's destructor and then call free to release the memory.
--
Ian Collins.
Exactly.., Thank You All, for clarifying my doubts..,
Pranav
--There's a difference between knowing the path and walking it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it seems that Ruby has the potential to compete
with and displace Python. I'm curious on what basis it...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Lindon |
last post by:
Until now I've been programming straight console apps, and all I've
been doing to compile is a simple 'gcc file1.cpp file2.cpp ....'.
What more is there to know about the compiler? I'd like to know
exactly what happens during each step. Is the compilation of dll's
(and corresponding libs on *nix) possible with only the compiler and
no platform specifc libraries (like windows.h)? What am I missing out
on?
thanks,
lin
|
by: Sasha |
last post by:
Hi,
I am extending standard IEnumerator, and I was just wondering what is the
best way to make enumarator safe? What do I mean by safe? Detect deletes and
all...
My idea is to have private Guid state field in the collection, and every
time something is inserted or deleted from the collection, I will just
change the guid. Enumerator will just have to compare the guid received in
the begging to the current one. If they are different, the...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
| |
by: jacob navia |
last post by:
I would like to add at the beginning of the C tutorial I am writing
a short blurb about what "types" are. I came up with the following text.
Please can you comment?
Did I miss something?
Is there something wrong in there?
--------------------------------------------------------------------
Types
A type is a definition for a sequence of storage bits. It gives the
meaning of the data stored in memory. If we say that the object a is an
|
by: Mark Broadbent |
last post by:
this might sound like an obvious question but I have found that usually
these two evolve at the same time.
One of the biggest reasons for creating the abstraction in the first place
(in my opinion) is to create a reusable framework that can be applied to
similar projects. However I have found that if an abstraction is created
first during the development phase, when the implementation is occurring,
the functionality or intended behaviour...
|
by: rn5a |
last post by:
The different Page events in the page life cycle like Page_PreInit,
Page_Init, Page_Load etc. - are they different stages of the runtime
process?
Does a server send back the HTML output of an ASPX page to the browser
immediately after the runtime or are there any processes involved in
between the runtime & the time when the server sends the HTML output
back to the browser?
Thanks
|
by: Dave |
last post by:
I have a global.asax file with Application_Start defined and create some
static data there and in another module used in the asp.net application and
I realize that static data is shared amongst child apps of an IIS
application and can be used by multiple users during the application life
cycle and for multiple page loads for the same or different page under a
root application.
What I don't understand and need to know is whether that...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |