Need help getting this code to compile under VS.NET 2003 (compiles under VS6.0).

I'm tasked with converting a LARGE project from VS6.0 to VS.NET 2003.  Here
is a VERY scaled down version of an error I'm getting.  I must be getting
rusty, but the way to get around this compiler error is just not coming to
me.

If you need to compile this, just create a Win32 console app and specify to
add support for MFC, then copy this code into the cpp file and press
compile.


class CLogItem : public CObject
{
protected:
    virtual BOOL CheckConflict(CLogItem* pItem) const;
};

struct MapEntry; //forward declaration..
typedef CArray<MapEntry, MapEntry&> CMapEntryArray;

struct MapEntry
{
    bool CheckAllConflicts(CMapEntryArray &AryMapItems);
};

class CLIModifyObj : public CLogItem
{
    friend class CLogItem;
public:
    CMapEntryArray  m_aryMapItems;

protected:
    virtual BOOL CheckConflict(CLogItem* pItem) const;
};

BOOL CLIModifyObj::CheckConflict(CLogItem* pItem) const
{
    for(int i = 0, n = m_aryMapItems.GetSize(); i < n; i++)
    {
/*
---------------- Compilation error happens here.  It says: -----------------
c:\...\Conversion.cpp(76) : error C2662: 'MapEntry::CheckAllConflicts' :
cannot convert 'this' pointer from 'const MapEntry' to 'MapEntry &'

--------------------------------------------------------------------
*/
        if( m_aryMapItems[i].CheckAllConflicts(
((CLIModifyObj*)pItem)->m_aryMapItems)  )
            return true;
    }
    return TRUE;
}


0
lviolette (38)
6/24/2004 6:55:41 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
471 Views

Similar Articles

[PageSpeed] 37

Leo Violette wrote:

>I'm tasked with converting a LARGE project from VS6.0 to VS.NET 2003.  Here
>is a VERY scaled down version of an error I'm getting.  I must be getting
>rusty, but the way to get around this compiler error is just not coming to
>me.
>
>If you need to compile this, just create a Win32 console app and specify to
>add support for MFC, then copy this code into the cpp file and press
>compile.
>
>
>class CLogItem : public CObject
>{
>protected:
>    virtual BOOL CheckConflict(CLogItem* pItem) const;
>};
>
>struct MapEntry; //forward declaration..
>typedef CArray<MapEntry, MapEntry&> CMapEntryArray;
>
>struct MapEntry
>{
>    bool CheckAllConflicts(CMapEntryArray &AryMapItems);
>};
>
>class CLIModifyObj : public CLogItem
>{
>    friend class CLogItem;
>public:
>    CMapEntryArray  m_aryMapItems;
>
>protected:
>    virtual BOOL CheckConflict(CLogItem* pItem) const;
>};
>
>BOOL CLIModifyObj::CheckConflict(CLogItem* pItem) const
>{
>    for(int i = 0, n = m_aryMapItems.GetSize(); i < n; i++)
>    {
>/*
>---------------- Compilation error happens here.  It says: -----------------
>c:\...\Conversion.cpp(76) : error C2662: 'MapEntry::CheckAllConflicts' :
>cannot convert 'this' pointer from 'const MapEntry' to 'MapEntry &'
>
>--------------------------------------------------------------------
>*/
>        if( m_aryMapItems[i].CheckAllConflicts(
>((CLIModifyObj*)pItem)->m_aryMapItems)  )
>            return true;
>    }
>    return TRUE;
>}

CheckConflict is a const member function. Thus, inside it, m_aryMapItems is
also const. VC.NET's const form of CArray::operator[] returns the object by
const reference, hence the error message. You can this by making
CheckAllConflicts const.

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
6/24/2004 7:12:50 PM
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:2j9md05dsank007j5m4q77vlu6kooknnro@4ax.com...
> Leo Violette wrote:
>
> >I'm tasked with converting a LARGE project from VS6.0 to VS.NET 2003.
Here
> >is a VERY scaled down version of an error I'm getting.  I must be getting
> >rusty, but the way to get around this compiler error is just not coming
to
> >me.
> >
> >If you need to compile this, just create a Win32 console app and specify
to
> >add support for MFC, then copy this code into the cpp file and press
> >compile.
> >
> >
> >class CLogItem : public CObject
> >{
> >protected:
> >    virtual BOOL CheckConflict(CLogItem* pItem) const;
> >};
> >
> >struct MapEntry; //forward declaration..
> >typedef CArray<MapEntry, MapEntry&> CMapEntryArray;
> >
> >struct MapEntry
> >{
> >    bool CheckAllConflicts(CMapEntryArray &AryMapItems);
> >};
> >
> >class CLIModifyObj : public CLogItem
> >{
> >    friend class CLogItem;
> >public:
> >    CMapEntryArray  m_aryMapItems;
> >
> >protected:
> >    virtual BOOL CheckConflict(CLogItem* pItem) const;
> >};
> >
> >BOOL CLIModifyObj::CheckConflict(CLogItem* pItem) const
> >{
> >    for(int i = 0, n = m_aryMapItems.GetSize(); i < n; i++)
> >    {
> >/*
> >---------------- Compilation error happens here.  It
says: -----------------
> >c:\...\Conversion.cpp(76) : error C2662: 'MapEntry::CheckAllConflicts' :
> >cannot convert 'this' pointer from 'const MapEntry' to 'MapEntry &'
> >
> >--------------------------------------------------------------------
> >*/
> >        if( m_aryMapItems[i].CheckAllConflicts(
> >((CLIModifyObj*)pItem)->m_aryMapItems)  )
> >            return true;
> >    }
> >    return TRUE;
> >}
>
> CheckConflict is a const member function. Thus, inside it, m_aryMapItems
is
> also const. VC.NET's const form of CArray::operator[] returns the object
by
> const reference, hence the error message. You can this by making
> CheckAllConflicts const.
>
> -- 
> Doug Harrison
> Microsoft MVP - Visual C++

Ahhh!  I didn't look very thoroughly at the problem.  Lights went off in my
head as I read your reply.  Thanks!


0
lviolette (38)
6/24/2004 7:41:13 PM
Reply:

Similar Artilces:

Outlook needs Outlook Express to work
I've installed my Outlook 2002 on my new Vista PC (I had Xp before). Now when I start Outlook it says "requires Outlook Express 4.01 or greater". I've been looking for Outlook Express to download and install but no joy. No CD came with my new Vista PC. Any ideas, short of buying a more modern Outlook? Vista doesn't actually support Outlook 2002 or older. Outlook Express is part of Internet Explorer but with the advent of Vista, it was switched to Windows Mail. There is no more Outlook Express. You could attempt however to create a profile using workgroup or c...

Outlook 2003 keeps crashing #2
I get this message when I look in System information. Outlook keeps crashing quite often. I cannot for example delete two messages without outlook crashing. My colleagues do not have this problem. We are using the Microsoft mail exhange server. Faulting application outlook.exe, version 11.0.5510.0, stamp 3f1380f0, faulting module mso.dll, version 11.0.5606.0, stamp 3f334cce, debug? 0, fault address 0x003b6e16. Does anyone has a solution?=20 Best regards/ Bj=F6rn 1) I would definitely apply Service Pack 2for Office 2003 + applicable critical security updates. 2) Have you tried starting O...

Password Issue with MS Money 2003
Hello, I am not familiar with newsgroups but I hope it is a forum to seek assistance. I am unable to reach MS support via email from my home computer on this issue. My Money 2003 requires a net passport password to open my account in Money that I have successfully accessed for approximately 12 months. It does not recognize my password now. I have attempted several times with my existing password, changed my net passport password, even uninstalled and re- installed MS Money 2003 to gain access to my account. Nothing has worked. Each time it states I have failed to enter the corr...

Exchange 2003 new install can not receive external email.
I have just setup a new Windows Server 2003 standard edition with Exchange 2003 standard edition on it. I have been working for a while trying to get it to receive external email. I can send out and send/ receive internal messages, but when someone trys to send me a message from outside our network they get the following returned mail message This Message was undeliverable due to the following reason: Each of the following recipients was rejected by a remote mail server. The reasons given by the server are included to help you determine why each recipient was rejected. Recipient: <**...

Outlook 2003 and "Check Names"
Hi, We are testing Outlook 2003 at our office now and there is one very frustrating "feature" that is bugging all of us. When we create a new e-mail message and type in the first name of a person from the global address book and hit ctrl- k to check the name...we get a response that Outlook doesn't recognize the name and there are "no suggestions". The only way Check Name will successfully resolve the name is if we type it last name first (ie, Gates, Bill). This was not the case in Office XP or Outlook 2000. You could search by first name (or partial first name)...

Copy entire row where CellValue=0
I need to loop through the collumn and search for value that is more then 0. When I find it I need to copy whole row and paste it 2-3 rows below the table. I tried to select the collumn and search the selection but for some reason I copy and paste only one row. Thank you for any help. Hi as a starting point: http://www.rondebruin.nl/copy5.htm -- Regards Frank Kabel Frankfurt, Germany "OxanaB" <OxanaB@discussions.microsoft.com> schrieb im Newsbeitrag news:8628F791-CF2D-480A-9EBF-6C31BCEF0293@microsoft.com... > I need to loop through the collumn and search for value tha...

Addressing within Exchange 2003
We are running Exchange 2003 SP2. We setup an MX record for a external email(alumni.cup.edu) these mailboxes do not exist within our exchange org. But when we send email to these externals email mailboxes we are getting the following NDRs: #5.5.0 smtp;550 Mailbox unavailable. #5.4.0 Is there a way in exchange to ignore these email address so that we don't get the NDR from within our Exchange Org? On Fri, 4 Aug 2006 08:08:02 -0700, Sabo, Eric <sabo_e@cup.edu> wrote: >We are running Exchange 2003 SP2. We setup an MX record for a external >email(alumni.cup.edu...

how do i add "Software Digrams" Folder in my Visio 2003
how do i add software diags folder in visio 2003 version. Like if i go to File->New it shows folders like brainstorming, project schedule, block diagrams but in my case its missing the Software Diags folder which contains activity diags, web mock ups, use case diags etc. please let me know how to get that template. thanks. Ankur What edition of Visio are you using? Check by going to the About Microsoft Office Visio dialog from the Help menu. "Ankur" <Ankur@discussions.microsoft.com> wrote in message news:F0D10BF0-A059-4A9C-B615-B99F3916F4E5@microsoft.com... > how...

Need help with Auto Filter
I have a spreedsheet that is filtered in multiple columns. I am running a "Subtotal" function to count certian rows when I filter the column. My question is this. Is there a way to save or freeze the data that the subtotal function counts in a different cell. In other words I want subtotal to count everything in a particular column but I want to be able to save that number somewhere so that when I filter again with another variable I am able to still view the first subtotal to compare the two. I hope this makes sense and thanks in advance for any assistance you can provi...

Install Exchange 2003 Server on new Hardware with same name
I got a new server to move my Exchange Server Installation. I want to keep the name I'm using now for my Server. Already read TechNet Article "How to Move Exchange Server 2003 to New Hardware and Keep the Same Server Name". Is there anything else that I should be aware of that is not on this TechNet article? I'm using a different Disk Configuration, does this matters? Should this be a smooth process? Thanks for any help you can give. The drive letters MUST match, because the paths of the databases are at the Active Directory. The disks can have different sizes than the or...

Adding Industry Codes
I am picking up the pieces on a previous installation of CRM, and want to add additional industries to my industry dropdown in the Lead form. For the life of me, I can't find the proper table in the database. Can someone be good enough to point me in the right direction? Thanks, Chris Chris, You don't do this via a table, you need to do it via form customization. You will need system admin rights, then go into System Customization and modify the Lead form. After making the changes, you will need to publish the change via Deployment Manager and issue an IISRESET. Matt "Chris...

"Save" preferences getting lost
List members: I work on long documents and want to save my work frequently. Every time I set the "Save" preference to a brief interval like five or ten minutes, the preferences seemingly resets itself to a default of thirty minutes. I'm using Word 2008 for the Mac on an Intel running 10.6.2. Thanks in advance for any thoughts. - Mark Pavlick Hi Mark: That indicates that your user ID does not have permission to write to the preference file that Word is using, or that something is replacing the preference file. With the help of your System...

[Exchange 2003] Mail enabled public folder and sender address
I have a Windows 2003 domain with a native mode Exchange 2003 organization; there are some mail enabled public folders. When a user replies to a message in a public folder, the outgoing mail's sender address is the user's one; I want it to be the public folder's one, or at least I'd like the "reply-to" address to be set to the public folder's. How can I accomplish this? Thanks Massimo You would need to grant the user permissions to be able to Send As the public folder. By default, when you reply to a message that is in a PF, the PF is not composing the ...

Help with income/expenses
Running 2003 in home page I setup income and expenses I prefer to see one whole month. Money some how shows it as 1/22/2006 through 2/20/2006 any way to fix this? Thanks Jeff ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- ...

How to get rid of personal folders view in nagivation pane with MA
Hi, trying to help a friend who migrated to hosted mail with MAPI. She is running Oultlook 2003 with latest updates. In the navigation there are personal folders and MAPI folders. The personal folders always show at top and expanded, with the MAPI folders below and not expanded. She only wants to see the MAPI folders expanded in the navigation view. I tried deleting the personal folders and it would not let me and it will not let you deliver to MAPI, which I understand why. Does anyone know how to make this happen? Thanks. Is this a hosted Exchange account? You can change the...

Outlook 2003
Hello, we have one client pc with Outlook 2003 where the following problem occurs: if a mail is replied from a user created sub folder of the inbox, the reply will not appear in sent mails, but will end up in the same sub folder, sender and recipient appear as identical. The mail goes out properly though, it's just that Outlook sets internally sender = recipient and bounces the reply back to the subfolder in which the original mail is stored. This happens on a Win 2000 machine with SP4 and all updates, the other clients use Outlook 2000 or XP and there is no such problem. There are no ru...

help with simple maths in excel
I want to do a simple arithmatic excercise in excel for my grand daughter. It is stuff like 2+2 =4 Smart me has hit a problem at the first hurdle... I need to put 2 in one cell the + in another cell and then 2 in another = in another and then she puts the answer in the next one. So the above would have 4 cells completed and she would put the answer in the 5th one. When I use the + or = sign in a cell of its own it (excel) thinks I am doing an equation, is there a way around this? I will work on the answer like if she gets it correct or wrong how I will do that...a sound or som...

HELP! Need to export hourly sales data on POS (NOT RMS)
How can I export hourly sales data across a date range? For instance, I want to show hourly sales for the month of October so I can graph it and post it in our break room. If I can't export hourly data, can I export daily sales? The built-in reports don't address this data format. This is a multi-part message in MIME format. ------=_NextPart_000_008E_01C826DC.CBC512D0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit Mark, This should work for you. Keep in mind it takes up to 5-10 minutes to load...

Exchange 2k3 imap VS startup
I have an E2k3 SP1 enterprise edition server. Whenever I reboot, the IMAP4 Virtual server does not start back up. I have to go into Exchange System Manager and manually start it. How do I make it start automatically? Tim How is the service set up - to start manually or automatically? Also, I'd check the dependencies the service has. It may be that it's trying to start before the other services have completed starting. Missy "Tim" <tjc7546@yahoo.com> wrote in message news:u14PBseFFHA.3120@TK2MSFTNGP12.phx.gbl... I have an E2k3 SP1 enterprise edition serve...

Need Query Help
I have two tables, Table A & Table B, in my database that have the same fields (Name, SSN, etc). Most of the records in both tables are identical, but each table has some unique records. I would like to run a query that will select the unique records in Table A by comparing SSNs, and then do the same for Table B. I am a database novice, and have tried all the wizards and expression builders with no luck. Any help at all would be appreciated. Thank you!!! Scott Casa Grande, AZ Hi Scott, The "Find Unmatched Query Wizard" is what you need. If you only want to check for SSNs ...

Outlook freezes after sending one email after upgrading 4.0
We just upgraded from 3.0 to 4.0 this weekend. All client machines have had the desktop client upgraded and 2 have the same issue. One is XP with Outlook 2003 and the other is Vista with Outlook 2007. Open opens and the CRM addin initializes correctly. As soon as you compose and send an email, Outlook locks up and you have to kill the process in task manager to close Outlook. I've had the same problem and have tried all I can think of...how did you fix this issue? Thank you. "Sander" wrote: > We just upgraded from 3.0 to 4.0 this weekend. All client machines have...

Import from Eudora 6 to Outlook 2003
I am trying to import messages from Eudora 6 to Outlook 2003. I am receiving the error message "The mail folder could not be opened. If another application is using this file, please close and try again. No other applications are running Thanks for any help see article 257354 of the microsoft knowledge base on http://support.microsoft.com: "Outlook Cannot Import Eudora Messages When Eudora Mail Is Stored in a Non-Default Location" ciaos >-----Original Message----- >I am trying to import messages from Eudora 6 to Outlook 2003. I am receiving the error message ...

Excel Problem
I have a 23.8 meg excel 2000 spreadsheet set for manual calculation saved to my local hard drive. Every time I try to open it, it takes forver and sometimes never opens but I do not get any error messages, let me just tell you that I am running a P4, 1 GB memory, Office 2K with SP3, and nothing else running when I try to open it. As I said it is set for manual calculation, and it is cleared to not auto calculate when opening or closing. Any idea's as to why this is happening? -- Todd I don't know why you're having this problem but I would like to point something out for w...

Help with a simple database
I am attempting to use Excel to develop a simple database for my office. The database basically lists a variety of orders purchased from various vendors, and my goal is to categorize and sort each vendor seperately. For example: GC Group 4/24/03 7831.1 $1,000.00 Alpha 1/20/03 7003.1 $2,000.00 Chandler 5/6/03 7050.1 $345.50 Is what the main chart looks like. Now, what I'm trying to accomplish is, suppose I added Tomsen 4/20/03 7873.1 $200.00 to the very bottom, Excel would automatically create a new tab (or even worksheet, if possible) tit...

Upgrade CRM 4.0 Professional to CRM 4.0 Enterprise
When I enter the CRM license code in the Deployment Manager to upgrade to Enterprise I get a message "The license code entered is not valid for upgrade. Make sure you have entered the license code correctly, and then try again". Do I have to reinstall CRM 4 to install Enterprise? Hi, what is your current installation? Professional? Have you entered trial version license keys ? /Aamir Current is Professional. I got the key from our MSDN subscription which didn't indicate a trial license. I was able to install the Enterprise edition on a test server using the same key w...