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 15 1852
Pranav wrote:
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
Well what did you expect? j1 wasn't dynamically allocated.
--
Ian Collins.
Pranav ha scritto:
delete( &j1);
Where is its previous new?
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?
Pranav wrote:
>
Ya I know that thing,
What thing? Keep enough context for your reply to make sense.
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?
What did you expect? You broke the rules by attempting to delete
something that wasn't dynamically allocated, so your runtime barfed.
--
Ian Collins.
On 8 Aug, 12:05, Pranav <pranav...@gmai l.comwrote:
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?
You should not call delete on something that was not allocated using
new (Except the null pointer). jl is an automatic object, so it will
be destroyed automatically.
DP
On Aug 8, 3:05*pm, Pranav <pranav...@gmai l.comwrote:
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?
The sequence of runtime action for delete (&j1)
is:-
1. The operator delete calls the destructor for the object at the
address &j1. So your cout displays "Here We Are".
2. The second step that the operator delete has to do is free the
memory, but since, the memory in case of &j1 was NOT allocated with
new, a runtime assertion failure is reported.
HW
On Aug 8, 4:19 pm, HumbleWorker <amardeep.devel o...@gmail.comw rote:
On Aug 8, 3:05 pm, Pranav <pranav...@gmai l.comwrote:
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?
The sequence of runtime action for delete (&j1)
is:-
1. The operator delete calls the destructor for the object at the
address &j1. So your cout displays "Here We Are".
2. The second step that the operator delete has to do is free the
memory, but since, the memory in case of &j1 was NOT allocated with
new, a runtime assertion failure is reported.
HW
Thank You HumbleWorker for complete explanation..,
Do anyone have any link/document to memory allocating function
implementation? (malloc,new,etc ..)
Pranav wrote:
On Aug 8, 4:19 pm, HumbleWorker <amardeep.devel o...@gmail.comw rote:
>On Aug 8, 3:05 pm, Pranav <pranav...@gmai l.comwrote:
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?
The sequence of runtime action for delete (&j1) is:-
1. The operator delete calls the destructor for the object at the address &j1. So your cout displays "Here We Are".
2. The second step that the operator delete has to do is free the memory, but since, the memory in case of &j1 was NOT allocated with new, a runtime assertion failure is reported.
HW
Thank You HumbleWorker for complete explanation..,
Do anyone have any link/document to memory allocating function
implementation? (malloc,new,etc ..)
I have a link: http://www.google.com/search?q=malloc%20implementation
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'. The destructor
will work, 'free' fails, since j1 wasn't allocated on the heap. In the
free call, there is probably an assertion that fails (if you are using
the debug version of the runtime lib) or a memory protection error. 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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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.
| |