Multiple inheritance problem

Hi,

I want to make a class, JNDlg, which is derived from two MFC-classes
(CDialog and CStringArray). The class declaration (a bit simplified) looks
as follows:

class JNDlg : public CDialog, public CStringArray
{
        // Construction
        public:
         JNDlg(CWnd* pParent = NULL);   // standard constructor

        // Dialog Data
         //{{AFX_DATA(JNDlg)
         enum { IDD = IDD_JNW };
         //}}AFX_DATA

         //{{AFX_VIRTUAL(JNDlg)
         protected:
         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV
support
         //}}AFX_VIRTUAL

        protected:
         //{{AFX_MSG(JNDlg)
         //}}AFX_MSG
         DECLARE_MESSAGE_MAP()
};

And the constructor is:

JNDlg::JNDlg(CWnd* pParent /*=NULL*/)
                : CDialog(JNDlg::IDD, pParent), CStringArray()
{
 //{{AFX_DATA_INIT(JNDlg)
 //}}AFX_DATA_INIT
}


As I compile this (I use MSVC 5.0) I get an error C2385 saying that
JNDlg::delete is ambigious.
This is understandable: both CDialog and CStringArray are derived from
CObject, so an instance of JNDlg has 2 CObject-instances and I don't blame
MSVC for not knowing which instances delete-operator to use ;-)

I can 'solve' this by making JNDlg own delete-operator.
This is in the JNDlg-declaration declared as:

      void PASCAL operator delete(void* p);

and defined as follows:

void PASCAL JNDlg::operator delete(void* pbData)
{
        CDialog::operator delete(pbData);
        CStringArray::operator delete(pbData);
}

The compiler doesn't complain about this and my program seems to work fine.
However I wonder if this solution is right. Deleting 'pbData' twice looks
very suspicious to me!

I will be very grateful if someone has a better solution or can confirm that
my solution is right...

TIA, Jos Landsheer




0
joslan (6)
7/30/2003 2:56:50 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
718 Views

Similar Articles

[PageSpeed] 24

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfcnotes_tn016.asp
-- 
Jeff Partch [VC++ MVP]


"Jos Landsheer" <joslan@xs4all.nl> wrote in message
news:3f27dcfb$0$131$e4fe514c@dreader5.news.xs4all.nl...
> Hi,
>
> I want to make a class, JNDlg, which is derived from two MFC-classes
> (CDialog and CStringArray). The class declaration (a bit simplified)
looks
> as follows:
>
> class JNDlg : public CDialog, public CStringArray
> {
>         // Construction
>         public:
>          JNDlg(CWnd* pParent = NULL);   // standard constructor
>
>         // Dialog Data
>          //{{AFX_DATA(JNDlg)
>          enum { IDD = IDD_JNW };
>          //}}AFX_DATA
>
>          //{{AFX_VIRTUAL(JNDlg)
>          protected:
>          virtual void DoDataExchange(CDataExchange* pDX);    //
DDX/DDV
> support
>          //}}AFX_VIRTUAL
>
>         protected:
>          //{{AFX_MSG(JNDlg)
>          //}}AFX_MSG
>          DECLARE_MESSAGE_MAP()
> };
>
> And the constructor is:
>
> JNDlg::JNDlg(CWnd* pParent /*=NULL*/)
>                 : CDialog(JNDlg::IDD, pParent), CStringArray()
> {
>  //{{AFX_DATA_INIT(JNDlg)
>  //}}AFX_DATA_INIT
> }
>
>
> As I compile this (I use MSVC 5.0) I get an error C2385 saying that
> JNDlg::delete is ambigious.
> This is understandable: both CDialog and CStringArray are derived from
> CObject, so an instance of JNDlg has 2 CObject-instances and I don't
blame
> MSVC for not knowing which instances delete-operator to use ;-)
>
> I can 'solve' this by making JNDlg own delete-operator.
> This is in the JNDlg-declaration declared as:
>
>       void PASCAL operator delete(void* p);
>
> and defined as follows:
>
> void PASCAL JNDlg::operator delete(void* pbData)
> {
>         CDialog::operator delete(pbData);
>         CStringArray::operator delete(pbData);
> }
>
> The compiler doesn't complain about this and my program seems to work
fine.
> However I wonder if this solution is right. Deleting 'pbData' twice
looks
> very suspicious to me!
>
> I will be very grateful if someone has a better solution or can
confirm that
> my solution is right...
>
> TIA, Jos Landsheer
>
>
>
>


0
jeffp (1711)
7/30/2003 3:07:22 PM
Reply:

Similar Artilces:

Problem
Outlook 2007 stops working every time 10 seconds after I run it under Windows Vista. In the event viewer I have this: Faulting application OUTLOOK.EXE, version 12.0.4518.1014, time stamp 0x4542840f, faulting module ntdll.dll, version 6.0.6000.16386, time stamp 0x4549bdc9, exception code 0xc0000374, fault offset 0x000af1c9, process id 0xc30, application start time 0x01c747849b157af9. I tried to solve the problem with no success by doing this: 1. Reinstall/repair outlook 2007 2. disabled all the adding in Outlook 2007. Any idea how to solve it ? thanks ra294 Y.A Just guessing but, the...

Removing multiple hyperlinks
I've got data copied into my spreadsheet that includes hyperlinks. Ther are thousands of these in a column. I can remove individually by right-clicking and selecting Hyperlink an Remove. I can then arrow down and do a control Y, cell by cell, What I want to do is highlight the column and be able tp remove th hyperlinks all at once. I've exhausted myself peering through knowlegebases and groups, bu cannot find any way to make this work. Thanks for any input you can provide -- Message posted from http://www.ExcelForum.com Hi one way: Use the following macro to remove hyperlinks...

Create a list with multiple criteria
I have a data base with 1,000's of addresses w/zipcodes (Sheet 1 columns A to E, E being zipcodes). After setting a base address I get all of the zipcodes within a given radius (in this case 70 zipcodes), listed in Sheet 2, Column A. Next, I use COUNTIF (in column B) to find how many addresses are in each zipcode, in this example there are 46 addresses within the 70 zipcodes. What I want to do is create a list in sheet three that will list each with the data from Sheet 1 columns A to E). Any help would be appreciated. Ronbo ...

Login / password problem
When attempting to launch money, after entering my .net username and password, I receive an error message "the password you entered was incorrect. Please try again. You may have made a typing error or typed the password for a different file" I am positive of the username and password,as I have used it since I installed money. I am able to successfully login to .net to open my hotmail account. Did you recently reinstall Money? If so, did you use the same version? If you didn't recently reinstall Money, there was another situation that was the subject of maybe a thousan...

RPC Connectivity problem?
I recently did a domain migration from NT4 to 2003/Active Directory as well as a migration from Exchange 5.5 to 2003. Everything was well while operating in mixed mode with both Exchange 5.5 and 2003 sites running. In addition, I could see Exchange attribute tabs in AD user properties. After I removed the only 5.5 site and uninstalled the AD connector, switched to Exchange 2003 native and Server 2003 native, I now have the following symptoms. 1) Cannot see any Exchange attribute tabs in AD user properties. 2) the Exchange Server application log is reporting an error about every 70 m...

A problem installing Office Enterprise 2007
I bought the Office Enterprise 2007 through the Microsoft Home Use Program (from my employer). No problem with installing but everytime that I switched on the computer and opened the Office program no matter which one of them, it will run the set up, activating the software and so forth. It takes about 10-15 minutes to open it. I can use any of the programs such as Words, Excels etc. after that without any problem but if I switched off the computer then I would go through the same process again next time... I have contacted the help desk and I was told to clean up the old Offic...

XmlSerializer: Inheritance and Read-Only Properties
All, Please maximize for easier viewing. Assume I have a class structure as follows: [Serializable] public class Foo { private string _hello = "Hello"; public string Hello { get { return _hello; } } } public class Bar : Foo { private Foo _fooBar = new Foo(); private string _message = "This is a test"; public Foo FooBar { get { return _fooBar; } } public string Message { get { return _message; } set { ...

Date Formatting problem #2
I have a excel (professional xp). I have a problem formatting a text field into a date field. When I format the field nothing happens, until I double click on the field and then it formats. The problem is that I have over 8000 lines and I can't do this for every field. Does anyone have any ideas? Thanks, Rick Rick Enter 1 in a blank cell and copy it. Highlight the 'dates' and Edit>Paste special...>Values+Multiply. With them still highlighted, reformat them as Date (Format>Cells...Number.Date). Don't worry that they all look like numbers before formatting....

Charting multiple multiples
Hopefully I can explain this in a way that will be understood. Data: Place A Place B Place C FWD Back FWD BACK FWD Back Org_1 1 2 3 2 1 3 Org_2 2 5 4 6 1 4 I would like to place the data so that FWD and Back data is stacked on top of each other in different colors, and placed in one row on a 3-D chart as Org-1 and a second row as Org_2. Any ideas? Thanks. If you arrange your data like this: Back FWD Org_1 Place A 2 1 Place B 2 3 Place C 3 1 Org_2 Place A 5 2 ...

Microsoft Office Access has encountered a problem
I try to open an MDB and get the following Microsoft Office Access screen: Microsoft Office Access has encountered a problem and needs to close. We are sorry for the inconvenience. I then have the option to Send Error Report or Don't Send. Is there any way to get this MDB open so I can get access to all the code I have written in there? Try to open it while holding down the shift key until the database opens. Here are links to mvp's articles on recovering from and preventing corruption http://allenbrowne.com/recover.html http://allenbrowne.com/ser-25.html http...

Simple Cut and Paste Problem
I am in a new worksheet, and am creating a very simple formula "=D3/C3". The result shows $5.20 in cell E3. When I cut and paste (or drag) to repeat this function all the way down my worksheet, Excel is putting in $5.20 in each cell. Can anyone tell me what I need to do to fix this? Thanks, Lance Hold down the CTRL key as you drag the formula down the column. "Lance Gray" <anonymous@discussions.microsoft.com> wrote in message news:4e5501c42c67$08a289e0$a301280a@phx.gbl... > I am in a new worksheet, and am creating a very simple > formula "=D3/C...

Multiple Hyperlinks In Same Shape Doesn't Work
Can anyone tell me how I can get multiple hyperlinks in the same shape to work? I have no problem inserting the hyperlinks, but they all point to only one. I scoured these posts, and found this (http://groups.google.com/groups?q=hyperlink+group:microsoft.public.visio.*&hl=en&lr=&ie=UTF-8&oe=UTF-8&group=microsoft.public.visio.*&selm=3eea6467%241%40news.microsoft.com&rnum=2), which doesn't appear to work. Thanks in advance-- RAD Um, which version of Visio are you using? As far as I know, at least Visio 2002 and Visio 2003 support multiple hyperlinks. Can't...

Multiple Profiles, multiple accounts, multiple machine configuring?
Is there a vb or related method of adding *both* profiles *and* email accounts to multiple users logins from the administrator account? I have a network which is a workgroup (NOT a domain), in which there are about 15 users that are replicated on each of 5 machines. I'd like to be able to add all 15 Mail Profiles, and all 15 email accounts to each of the 15 logins on these 5 machines--obviously with as little work as possible. The mail is all retrieved from the same Exchange Server, but these machines *cannot* be added to a domain (don't ask!). I'd hate to have to log into ...

Printer redirection problem in WinCE60
Hi, Thanks in Advance, I am facing problem in WINCE 6.0 printer redirction in RDP(Terminal Server). In X86 architure, connect two same LPT printer(model) to two respective WinCE60 OS(Thin Clients) in a network Only recent RDP Session printer is working, the older session printer is not working and flag the Error message. In Windows CE 50, it is working in all session Please suggest me if have information. With warm regards, Pradip Shinde Submitted via EggHeadCafe - Software Developer Portal of Choice WPF GridView Sample To Insert, Update, and Delete Recor...

date problem #10
Thanks a lot, Dave This piece of code works great. M P Redd -- mpredd ----------------------------------------------------------------------- mpreddy's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1327 View this thread: http://www.excelforum.com/showthread.php?threadid=26358 ...

distributing data into multiple cells
hii i have to prepare an exel sheet of some 2000 products..i have to copy d data from the net and then prepare the sheet,with 4 different columns for 4 diff types of entries..now when i copy data nad paste is as text.it all goes in a single cell in a row .how can i distribute the data l into multiple cells????????? -- jaspreet ------------------------------------------------------------------------ jaspreet's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23821 View this thread: http://www.excelforum.com/showthread.php?threadid=374772 can you show some samp...

ARGGG! OWA Problem
We are using Outlook Web Access with Exchange server 5.5 (on a Windows 2000 computer). For some strange reason, I cannot successfully connect anymore. I get either of the following errors. It's either 1) Failed to get inbox Or 2) Failed to connect to the Microsoft Exchange server, <server name> No other users seem to be affected, just me! I have checked permissions through the IIS management console, and I have even re-applied service pack 4 for Exchange 5.5. I can log on to the network and get my mail through Outlook on the desktop with no problem. I'm stumped! Any...

Single click selects multiple cells
When clicking on a single cell multiple cells are selected. The one time solution for this is to zoom in or out. This is problematic as 60% seems to be the zoom that works most of the time but at this zoom level the cell contents do not display. The time lost and the frustration that builds is killing my productivity and office attitude. Please give all of us a permanet fix. -- Thanks Mike ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" butt...

Is there a way to sort multiple columns with a tab or something?
I have a 4 column spreadsheet. I want to be able to click the heading for each of the columns to hav them sort by that column if clicked. How do I do that -- Message posted from http://www.ExcelForum.com Hi why not used the soprt icon for this. Note: This could screw up your sorting if Excel does not recognize your database columns correctly -- Regards Frank Kabel Frankfurt, Germany > I have a 4 column spreadsheet. > > I want to be able to click the heading for each of the columns to have > them sort by that column if clicked. How do I do that? > > > --- > Mess...

Sending to multiple addresses
How do I send an email to multiple addresses having only the recipient see their own email address? Michelle wrote: > How do I send an email to multiple addresses having only > the recipient see their own email address? Put the addresses into the BCC: field. Note that many e-mail programs will decide such mails are spam though. >-----Original Message----- >How do I send an email to multiple addresses having only >the recipient see their own email address? >. Open your new email and go to tools, select recipient, when your address book opens select (highlight) the a...

scatter chart x axis problem
The data is in three columns. My client wants the values in column 1 to also be the x-axis values. Is this possible? Nothing that I have tried has worked. Thanks in advance. Suzan Suzan - If you're making an XY Scatter chart, Excel automatically uses the first column as the X values, and uses the rest of the columns for Y values for one less series than you've selected columns. If you're making a line chart, Excel usually uses each column of data as Y values for another series, and uses counting numbers (1, 2, 3,..) for the category values. To help Excel realize what you...

Exchange 2000 Distribution Lists
Hello We are running an Exchange 2000 environment in Exchange Native Mode and Windows Mixed Mode. We just converted from Exchange 5.5 Is there any way to configure multiple people to be owners or editors of the distribution lists? This was possible in 5.5, but we cannot find a means of accomplishing this in 2000 Any help would be appreciated Thank yo Jason "Jason P.S." <jason.pruden-shebaylo@investorsgroup.com> wrote: >We are running an Exchange 2000 environment in Exchange Native Mode and Windows Mixed Mode. We just converted from Exchange 5.5. > >Is there any w...

multiple selection
How can I select multiple records into a list box? I want that for append identical records (for select records) in another table. Many thanks Florin Use a subform instead of a list box. In a subform bound to a related table, you can append as many rows as applicable. It is possible (but not simple) to use an unbound multi-select list box that is populated in the Current event of the form, and executes Append, Delete, and Update query statements based on the ItemsSelected if they are changed. You will also have to find a way to respond to the user "undoing" changes. -- Al...

Need to have a dropdown list containing multiple rows
I am setting up an form and need to create a dropdown list that will contain 8 sets of data. Each set needs to contain 3 rows of data (name, street address & city/state/zip. The goal is to allow the user to click onto the cell, see the dropdown and select which address set to use. This would then place the data into three rows suitable for mailing. I have never attempted anything like this and am in need of assistance. Thank you. --- Message posted from http://www.ExcelForum.com/ Pat What you ask is easily done using Data Validation drop-down list and a few Vlookups but........Ex...

Another callback problem
My project is dialog only MFC based application. I have the callback function detailed below. This has been registered with an API provided by the board manufacturer. No problem there after help from this group. When the callback occurs this function calls the LogEvents function. The decleration for this function and the body are shown below. I had to declare it static to be able to call it from the callback function. I then had to use the code shown to call the WriteLog function again below. This function is called by other code within the dialog class no problem and I wanted to reuse it. ...