473,394 Members | 1,946 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,394 software developers and data experts.

operator new local to a class is required ?

Hello

I have just read (in a MSDN article named Deep C++, in part 8) that
member functions operator new and operator delete (and operator new[]
and operator delete[]) are required in order to have the language
automaticaly delete a memory bloc alocated with _new_ after the
constructor for the new object throws.

Is it true that only class delete is called in a new expresion to free
memory after the constructor throw ?

I am trying to write an exception-safe application. Idealy the app will
never crash, but will pop-up a message box and exit gracefully with full
clean-up if a fatal error like access violation occurs, be it anywhere
in the flow of control in my app. However I find this to be such a
difficult task to do !! It is ever more complicated.

Do you know of a good book that will fully explain to me how to
effectively use exception-handling in a real application ? The problem
gets even worse if you work with the odd code and design required by
Win32 and Win32 GUI...

Thank you
Timothy Madden
Romania
Oct 31 '05 #1
1 1435
Timothy Madden wrote:
Hello

I have just read (in a MSDN article named Deep C++, in part 8) that
member functions operator new and operator delete (and operator new[]
and operator delete[]) are required in order to have the language
automaticaly delete a memory bloc alocated with _new_ after the
constructor for the new object throws.
I've just read that article and I can't see what you read that made you
come to that conclusion.

Is it true that only class delete is called in a new expresion to free
memory after the constructor throw ?
No.

I am trying to write an exception-safe application. Idealy the app will
never crash, but will pop-up a message box and exit gracefully with full
clean-up if a fatal error like access violation occurs, be it anywhere
in the flow of control in my app. However I find this to be such a
difficult task to do !! It is ever more complicated.
There is no doubt, it is a difficult task. You do have to consider
whether the effort needed is worth it.

Do you know of a good book that will fully explain to me how to
effectively use exception-handling in a real application ? The problem
gets even worse if you work with the odd code and design required by
Win32 and Win32 GUI...


There is the Exceptional C++ series by Herb Sutter, personally I hate
the style but they do contain good information.

John
Oct 31 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Mark A. Gibbs | last post by:
I'm having yet another headache with making a standard allocator. What behaviour should be expected from the assigment operator? When would it be called? Why is it there at all, when you can't...
7
by: Richard Hayden | last post by:
Hi, I have the following code for example: /**********************************/ #include <iostream> class C1 { public:
16
by: gorda | last post by:
Hello, I am playing around with operator overloading and inheritence, specifically overloading the + operator in the base class and its derived class. The structure is simple: the base class...
3
by: Tony Johansson | last post by:
Hello! I have this wrapper class Integer below that I use when testing operator overloading. But I run into problem. First this friend definition below that I have within class definition cause...
1
by: Tony Johansson | last post by:
Hello! I have this wrapper class Integer below that I use when testing operator overloading. A book that I read say that the expression Integer i; i+5 is translated to operator+(i,5) using the...
6
by: Geoffrey S. Knauth | last post by:
It's been a while since I programmed in C++, and the language sure has changed. Usually I can figure out why something no longer compiles, but this time I'm stumped. A friend has a problem he...
4
by: Abubakar | last post by:
Hi all, I downloaded a code (a c++ project) over the internet and at one place I saw the following lline: // allow usage as a pointer. operator CMemDC*() { return this; } (the comment up...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
14
by: Hunk | last post by:
Hi I ws wondering if there is a way to implement operator+ in case of virtual classes. Here's the problem. I have to have a base string class from which two classes (normal char string and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
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...

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.