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

delete() confusion!

Plus or minus a few typos, in the pseudo-program below, which delete
operator gets called, Base1's delete or the default delete?

Thanks for any help..

--
class Base1
{
public:
void operator delete(void *);
void * operator new(int size);
};

class Base2
{
public:
virtual ~Base2();

Dispose()
{
delete this;
}
};

class Derive : virtual public Base1, virtual public Base2
{
int MemberVar;
};

main()
{
Base2 * p = new Derive;
p->Dispose();
}
--
Jul 19 '05 #1
1 1506
Ian McBride wrote:
Plus or minus a few typos, in the pseudo-program below, which delete
operator gets called, Base1's delete or the default delete?
Neither, unless you have a suitable pseudo-compiler. Fix the "typos" and
add dummy function definitions which output suitable messages. That will
tell you what your real compiler thinks the answer should be.
Thanks for any help..

--
class Base1
{
public:
void operator delete(void *);
void * operator new(int size);
};

class Base2
{
public:
virtual ~Base2();

Dispose()
{
delete this;
}
};

class Derive : virtual public Base1, virtual public Base2
{
int MemberVar;
};

main()
{
Base2 * p = new Derive;
p->Dispose();
}
--


Good luck,
Buster.

Jul 19 '05 #2

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

Similar topics

19
by: Sandeep Grover | last post by:
Hi, If I do another delete on an object which has been deleted earlier, then how is the system expected to behave ? Is it an unpredictable behavior ?? Thanks Sandeep
2
by: Ian McBride | last post by:
(was: delete() confusion) I have a class with multiple base classes. One of these base classes (base1) has its own new/delete operators and nothing else. Another base class (base 2) has a...
3
by: David | last post by:
I have a problem that I cannot delete components that are placed on a Tabbed page in Visual Basic.Net 2003. (OS = Windows 2000 Professional) The form uses a Tab Control with several pages. I have...
20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
1
by: Swaq | last post by:
Or, at least, I find it complicated :-) Hopefully it is not that hard but here goes: I have two tables: Persons and Relations Persons contain personal data such as person_ID, name, adresse,...
4
by: Calvin Lai | last post by:
Hi all, Does anyone know how I could add a confirm (client side) feature on those Delete Linkbutton in DataGrid? Thanks,
7
by: Brian J. Ackermann | last post by:
Hi all, I'm getting an error from something that seems too easy to cause trouble. Here's the scenario. User fills out a form. User saves. On submit, an asp script attempts to save the data. ...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
29
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I remembered delete is implemented through operator overloading, but I am not quite clear. Could anyone recommend some links about how delete is implemented so that I can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
Oralloy
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,...
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...

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.