using CList as a base class in an extension DLL

Hi all. I must be doing something wrong but cannot figure it out.  I
have a data class and a list class, in an extension DLL, declared like
this:

>#define DllExport __declspec (dllexport)

>class DllExport CRate : public CObject {
>public:
>  DECLARE_SERIAL (CRate)
>  CRate () { m_Rate = 0; }
>  CRate (const CRate &in) { *this = in; }
>
>  const CRate&  operator= (const CRate& in)
>    { m_Rate = in.m_Rate; m_Date = in.m_Date; return *this; }
>
>  bool    operator== (const CRate& in);
>  bool    operator!= (const CRate& in) { return ! (*this == in); }
>
>  virtual void	Serialize (CArchive& Ar);
>
>  double    m_Rate;
>  CString   m_Date;
>};


>class DllExport CRateList : public CList <CRate, CRate&> {
>public:
>  DECLARE_SERIAL (CRateList)
>
>  double    GetRate () const { return GetHead ().m_Rate; }
>  double    GetRate (const CString &da) const;
>  void      SetRate (const double& d, const CString &da);
>
>  const CRateList&  operator= (const CRateList& in);
>
>  bool      operator== (const CRateList& in);
>  bool      operator!= (const CRateList& in)
>              { return ! (*this == in); }
>};

The implementation for serialization looks like this:

>IMPLEMENT_SERIAL (CRate, CObject, 1)
>IMPLEMENT_SERIAL (CRateList, CList, 1)


If I leave DllExport out of the class declarations, everything
compiles ok. It is still ok with DllExport only in the CRate class.
But when I put DllExport in the CRateList class, I get a compile error
like this:

 "error C2678: binary '==' : no operator found which takes a left-hand
operand of type 'const CRate' (or there is no acceptable conversion)"

This error is attributed to the last line of a helper function called
CompareElements that looks like this (from afxtempl.h):

>template<class TYPE, class ARG_TYPE>
>BOOL AFXAPI CompareElements(const TYPE* pElement1, const ARG_TYPE* pElement2)
>{
>  ENSURE(pElement1 != NULL && pElement2 != NULL);
>  ASSERT(AfxIsValidAddress(pElement1, sizeof(TYPE), FALSE));
>  ASSERT(AfxIsValidAddress(pElement2, sizeof(ARG_TYPE), FALSE));
>
>  return *pElement1 == *pElement2;
>}


As far as I can find, that helper is only called from CList::Find
function, which I am not using...  And anyway I cannot figure out why
this only happens when I use dllexport.

Help??

Thanks, Russ
0
Russ
11/12/2009 10:46:46 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1372 Views

Similar Articles

[PageSpeed] 46

See below...
On Thu, 12 Nov 2009 17:46:46 -0500, Russ <russk2t@comcast.net> wrote:

>Hi all. I must be doing something wrong but cannot figure it out.  I
>have a data class and a list class, in an extension DLL, declared like
>this:
>
>>#define DllExport __declspec (dllexport)
>
>>class DllExport CRate : public CObject {
>>public:
>>  DECLARE_SERIAL (CRate)
>>  CRate () { m_Rate = 0; }
>>  CRate (const CRate &in) { *this = in; }
>>
>>  const CRate&  operator= (const CRate& in)
>>    { m_Rate = in.m_Rate; m_Date = in.m_Date; return *this; }
>>
>>  bool    operator== (const CRate& in);
****
      bool    operator==(const CRate & in) const;
****
>>  bool    operator!= (const CRate& in) { return ! (*this == in); }
****
      bool    operator != (const CRate & in) const {return !(*this == in); }
****
>>
>>  virtual void	Serialize (CArchive& Ar);
>>
>>  double    m_Rate;
>>  CString   m_Date;
>>};
>
>
>>class DllExport CRateList : public CList <CRate, CRate&> {
>>public:
>>  DECLARE_SERIAL (CRateList)
>>
>>  double    GetRate () const { return GetHead ().m_Rate; }
>>  double    GetRate (const CString &da) const;
>>  void      SetRate (const double& d, const CString &da);
>>
>>  const CRateList&  operator= (const CRateList& in);
>>
>>  bool      operator== (const CRateList& in);
>>  bool      operator!= (const CRateList& in)
>>              { return ! (*this == in); }
>>};
>
>The implementation for serialization looks like this:
>
>>IMPLEMENT_SERIAL (CRate, CObject, 1)
>>IMPLEMENT_SERIAL (CRateList, CList, 1)
>
>
>If I leave DllExport out of the class declarations, everything
>compiles ok. It is still ok with DllExport only in the CRate class.
>But when I put DllExport in the CRateList class, I get a compile error
>like this:
>
> "error C2678: binary '==' : no operator found which takes a left-hand
>operand of type 'const CRate' (or there is no acceptable conversion)"
>
>This error is attributed to the last line of a helper function called
>CompareElements that looks like this (from afxtempl.h):
>
>>template<class TYPE, class ARG_TYPE>
>>BOOL AFXAPI CompareElements(const TYPE* pElement1, const ARG_TYPE* pElement2)
>>{
>>  ENSURE(pElement1 != NULL && pElement2 != NULL);
>>  ASSERT(AfxIsValidAddress(pElement1, sizeof(TYPE), FALSE));
>>  ASSERT(AfxIsValidAddress(pElement2, sizeof(ARG_TYPE), FALSE));
>>
>>  return *pElement1 == *pElement2;
>>}
>
>
>As far as I can find, that helper is only called from CList::Find
>function, which I am not using...  And anyway I cannot figure out why
>this only happens when I use dllexport.
>
>Help??
>
>Thanks, Russ
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
Joseph
11/13/2009 4:34:28 AM
On Nov 12, 11:46=A0pm, Russ <russ...@comcast.net> wrote:
> As far as I can find, that helper is only called from CList::Find
> function, which I am not using... =A0And anyway I cannot figure out why
> this only happens when I use dllexport.

You need bool op=3D=3D(...) __const__; // __ emphasis mine.

This is, I guess, because you are exporting a class that derives from
the template class. Since compiler does not know class will be used by
client code (it can't, that code is in another module), compiler
forces the generation of all members for given base class. Some of
these members use CompareElements. But your op=3D=3D is not correct (and,
you see, CompareElements takes const TYPE* and then calls op=3D=3D).

I wouldn't export like that. In CRateList, I would expose an interface
I think should be exposed (even if it is a bastardized CList part). I
would either contain CList in CRateList or perhaps derive privately.
What I am saying, BTW, stems from the general rule of thumb "prefer
containment to inheritance".

goran.
0
Goran
11/13/2009 7:40:52 AM
Thanks Joe (and Goran) for the help.  I must have looked at those
declarations 50 times - and still did not see that I had somehow
dropped the const from the operator== and operator!= functions.

Of course it works now.

Thanks again, Russ
 

On Thu, 12 Nov 2009 23:34:28 -0500, Joseph M. Newcomer
<newcomer@flounder.com> wrote:

>See below...
>On Thu, 12 Nov 2009 17:46:46 -0500, Russ <russk2t@comcast.net> wrote:
>
>>Hi all. I must be doing something wrong but cannot figure it out.  I
>>have a data class and a list class, in an extension DLL, declared like
>>this:
>>
>>>#define DllExport __declspec (dllexport)
>>
>>>class DllExport CRate : public CObject {
>>>public:
>>>  DECLARE_SERIAL (CRate)
>>>  CRate () { m_Rate = 0; }
>>>  CRate (const CRate &in) { *this = in; }
>>>
>>>  const CRate&  operator= (const CRate& in)
>>>    { m_Rate = in.m_Rate; m_Date = in.m_Date; return *this; }
>>>
>>>  bool    operator== (const CRate& in);
>****
>      bool    operator==(const CRate & in) const;
>****
>>>  bool    operator!= (const CRate& in) { return ! (*this == in); }
>****
>      bool    operator != (const CRate & in) const {return !(*this == in); }
>****
>>>
>>>  virtual void	Serialize (CArchive& Ar);
>>>
>>>  double    m_Rate;
>>>  CString   m_Date;
>>>};
>>
>>
>>>class DllExport CRateList : public CList <CRate, CRate&> {
>>>public:
>>>  DECLARE_SERIAL (CRateList)
>>>
>>>  double    GetRate () const { return GetHead ().m_Rate; }
>>>  double    GetRate (const CString &da) const;
>>>  void      SetRate (const double& d, const CString &da);
>>>
>>>  const CRateList&  operator= (const CRateList& in);
>>>
>>>  bool      operator== (const CRateList& in);
>>>  bool      operator!= (const CRateList& in)
>>>              { return ! (*this == in); }
>>>};
>>
>>The implementation for serialization looks like this:
>>
>>>IMPLEMENT_SERIAL (CRate, CObject, 1)
>>>IMPLEMENT_SERIAL (CRateList, CList, 1)
>>
>>
>>If I leave DllExport out of the class declarations, everything
>>compiles ok. It is still ok with DllExport only in the CRate class.
>>But when I put DllExport in the CRateList class, I get a compile error
>>like this:
>>
>> "error C2678: binary '==' : no operator found which takes a left-hand
>>operand of type 'const CRate' (or there is no acceptable conversion)"
>>
>>This error is attributed to the last line of a helper function called
>>CompareElements that looks like this (from afxtempl.h):
>>
>>>template<class TYPE, class ARG_TYPE>
>>>BOOL AFXAPI CompareElements(const TYPE* pElement1, const ARG_TYPE* pElement2)
>>>{
>>>  ENSURE(pElement1 != NULL && pElement2 != NULL);
>>>  ASSERT(AfxIsValidAddress(pElement1, sizeof(TYPE), FALSE));
>>>  ASSERT(AfxIsValidAddress(pElement2, sizeof(ARG_TYPE), FALSE));
>>>
>>>  return *pElement1 == *pElement2;
>>>}
>>
>>
>>As far as I can find, that helper is only called from CList::Find
>>function, which I am not using...  And anyway I cannot figure out why
>>this only happens when I use dllexport.
>>
>>Help??
>>
>>Thanks, Russ
>Joseph M. Newcomer [MVP]
>email: newcomer@flounder.com
>Web: http://www.flounder.com
>MVP Tips: http://www.flounder.com/mvp_tips.htm
0
Russ
11/13/2009 5:25:55 PM
Reply:

Similar Artilces:

Using stationary when Word is used as the editor
Hello, I am having a problem with stationary when using word as the email editor. What is required is for a logo to be placed as a backgroun image in the top right hand corner. this works fine in outlook using this code: <HTML> <HEAD> <STYLE> BODY { font-family: Arial; font-size: 10pt; color: 000000; background-position: right top; background-repeat: no-repeat; background-image: url(Pic.jpg); } </STYLE> </HEAD> <BODY> </BODY> </HTML> However when Word is used as the email editor the background image is no longer placed in the top righ...

Use Vista to restore windows mail from backup
I use Vista 32bit backup to backup my computer. Vista 32 bit backup is not a disk image backup. I will be reinstalling everything on my computer. I use Vista Windows Mail that came with my computer for my email. How do I use Vista restore from my latest backup to restore my emails and contacts and email accounts POP/SMTP settings? I assume Vista 32 bit backup backs this up. Vista help does not specifically address this. Thank You for your Help. Bob Background info: I have a desktop AMD 4400+ 64X2 4GB memory 320GB HD(way bigger than I need) Acer computer (AM3100-U3201A) I...

data entry using functions??????
I would like to type in one cell data and have data returned to another cell. Example: A1 B1 C1 D1...........H1...J1 K1 L1 data typed into H1 matches data in A1; I need data in B1 C1 D1 to return to J1 K1 L1. I would like to copy the formulas down in J1:L1 thru 30 or so rows but may have only 15 rows of data in A1:D1 Data entered in the H1:31 should match one of the entries in A1:15 and return the corresponding data in B,C,D 1:15 to the corresponding cells in J,K,L 1:31 I cannot figure out how to do this, the IF function won't do this in any format I can discern. Hope I have mad...

use license office 2008 for office 2007
hi, does the product key of office mac 2008 also work to validate an office 2007 edition (for windows)? thanks in advance, michael On 3/12/09 12:57 PM, in article 34F37494-E647-488A-B725-C05E577E671B@microsoft.com, "michael" <michael @discussions.microsoft.com> wrote: > hi, > does the product key of office mac 2008 also work to validate an office 2007 > edition (for windows)? > > thanks in advance, > michael No. -- Bob Greenblatt [MVP], Macintosh bobgreenblattATmsnDOTcom ...

Which to use and how to use it
I want to modify a Word document by adding a field from which users can select 1 item from a list of given alternatives. I have tried messing around with list and combo boxes but just cannot get them to do what I want. I use a combobox but cannot populate any selections. I use a listbox but cannot add any text. I do not know much about VBA (I assume this is VBA) so am asking questions for all sorts of things and hopefully the answer will be forthcoming. Thanks "Paul" <Paul@discussions.microsoft.com> wrote in message news:8268F02F-A644-4862-8479-358B646F...

Sorting Syntax using VB
Hello, I am a newbie to the use of VB and Excel. I am trying to sort the range on Sheet 1..order by Company, then by Date most recent date. Below is what I have but how can I make it acend? Worksheets("Sheet1").Range("A3:g400").Sort _ Key1:=Worksheets("Sheet1").Range("A1"), _ Key2:=Worksheets("Sheet1").Range("B1") Any thoughts and help is much appreciated. Kind Regards, Ray One thing that as a newbie you might try is to record a macro while you do what you want manually. For instance it might look something l...

Using Jet to read excel file returns blank for last cell
With VB6 I am opening an Excel file to query the contents using ADO. I am then using the contents of the worksheet to create a format file that is used for a bulk insert into SQL Server. We designed the program this way so that users can use a spreadsheet to import data in any format they want and process the data based on values set in the spreadsheet. This keeps us from having to design new tables and format files for new record layouts which come down pretty often. Everything works fine usually. There is just one perculiarity that is happening with the Excel file. Sometimes, th...

Excel menus are locked when opening an XLS file using IE
A financial website (www.investors.com) is publishing daily an Excel spreadsheet. When I click on the link, Internet Explorer asks me whether I want to save the file or open the file. When I choose "Open" the Excel file shows up nicely in my browser ... the IE menus change to Excel menus. Problem: I can only use the File menu choices; the other menus are LOCKED. Why? I'm using Office XP on Windows 2000 Professional. At work I'm using Office 2002 and things work fine. Is this an Office XP issue, or is ther somewhere a setting that I have to teak? Any help is mu...

Use ActiveX controls or the controls in VC
Dear all, I am designing a GUI dialog with MFC in VC6.0. I found that many controls in VC6 can be replaced with ActiveX controls. So one question: which one should we prefer to use? Do ActiveX controls have more advanced features allowing customising? Many thanks, Usually activex control brings extra file dependency to your executable, and sometimes they are licensed. So I would use windows standardard control if there is no special need for activex control. "Yuchun Xu" <breezexuyc@ntlworld.com> wrote in message news:%235%23nbYseGHA.3456@TK2MSFTNGP05.phx.gbl... >...

Using InStr to find a range of ASCII characters
Hello, I need to create a query that finds all the ascii characters from 192 to 255 and finds some others like 140, 158 & 159. I looked for a similar question in the forums and didn't find anything. Here is what I tried: Public Function FindChars(textIn As String) As String Dim strNameIn As String strNameIn = Nz(textIn, "") If InStr(1, strNameIn, Chr(192)-Chr(255)) > 0 Then Debug.Print strNameIn End If End Function Of course, this doesn't work. I tried a number of other variations also. Thanks for any ...

How do you use database
It is the first time i have ever used database and i donot now how to use it. The other problem i face is that i don't know what is for!!! so please can someone help I would recommend that you go to http://office.microsoft.com/en-us/training/FX100565001033.aspx and go thru the training tutorials. It will explain what a database is, etc. Using Microsoft Access will be a challenge for you if you don't have the basic understanding of what a database is. Definition of Database: A collection of related data. Access is a "relational" database. -- cw "Tink the Stink...

Symbols used in excel
Does anyone know where I can find a list of the symbols used in Excel formulas and what they mean? I am experimenting alot more with excel and having a usefull list would be great. To get a list of symbols, enter =CHAR(ROW()) in A1 and copy down to row 255. -- Regards Dave Hawley www.ozgrid.com "SarahN" <SarahN@discussions.microsoft.com> wrote in message news:7949574D-550E-4AF1-A9DD-82851F7D4AF8@microsoft.com... > Does anyone know where I can find a list of the symbols used in Excel > formulas and what they mean? > > I am experimen...

Using .NET XmlDocument Class, How to use a xpath expression on xml document which has a default namespace
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list "clear" with XPath Expression. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml( xmlText ); XmlNamespaceManager xsn = new XmlNamespaceManager( xmlDoc.NameTable ); xsn.AddNamespace( "", "http://test" ); string xPath = "//clear"; ...

Using Foxpro from within Ms Excel using macros
Does anyone now how to incorporate the foxpro code "=sys(3050,1,100000) into a VB macro so that the remote machines I am using restrict foreground/background buffer memory. The following is taken from Microsoft's own website.... "Using the commands COPY, APPEND, DELETE, INDEX, PACK or SQL-SELECT on a large table in Visual FoxPro causes long pauses while the data is being manipulated. The hard drive continues processing the data, but Visual FoxPro seems to be inactive. This happens because computers that have large amounts of RAM and are running Windows 95 or Windows NT g...

How to use Autocorrect?
I think I have Autocorrect set up right. None of the changes seem to occur when I input text. Is there a way to turn the feature on, other than the menu item under Tools? jlb Hi jlb, Do you have the option "Replace text as you type" selected? You need to enter exactly what is shown in the "replace" box. I hope this helps. Let us know how you get along. Julie Project MVP Visit http://project.mvps.org/ for the FAQs and additional information about Microsoft Project "jlbreyer" <jlbreyer@discussions.microsoft.com> wrote in message ...

How can I use the vlookup function to return a sum of the values?
Hi, I am trying to use the vlookup function to return several values as 1 result into 1 single cell. For example, i have a spreadsheet which lists several different dpeartments. These departments may be repaeted many times in the spreadsheet. I need a sum of thoses values to be returned in a separate cell using the vlookup function. Can someone help me on this please? Thanks Chaandni Wrote: > Hi, > > I am trying to use the vlookup function to return several values as 1 > result > into 1 single cell. For example, i have a spreadsheet which lists > several > differ...

'REFTASKOWNERID' : macro redefinition, when converting Consoleapp to DLL
I'm getting some errors and a warning when I'm attempting to convert some classes from a ConsoleApp to a DLL. This should be irrelevant since I'm just swiping classfiles from the Console app so there must be some inclusion problem from a different header file... I just dont' know what is going on. Aside from the warning I'm getting in the subject, I'm getting: Error 1 error C2365: 'SHCOLSTATE_TYPE_STR' : redefinition; previous definition was 'enumerator' c:\program files\microsoft visual studio 8\vc\platformsdk\include\shobjidl.h 1948 A bunch of time...

Use the corrective update from MS Corp.
--yguttddiaswmk Content-Type: multipart/related; boundary="hkntzgxooejuz"; type="multipart/alternative" --hkntzgxooejuz Content-Type: multipart/alternative; boundary="jqpsaghc" --jqpsaghc Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS Consumer this is the latest version of security update, the "September 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to protect y...

Using Roundup in an IF Statement
This is probably simple but I can't get it to work. I need to have the number in D10, if is less than 50000, rounded up to the nearest hundred. Then I need to apply the formula (((D10/1000)*0.23)*12) to the rounded up number. If the number in D10 is 50,000 or more, the formula should return a hard number, in this case it will be 138. =IF((D10*1)<50000, roundup ((d10*1),2), (((D10/1000)*0.23)*12),138) On Tue, 8 Dec 2009 11:14:33 -0800 (PST), LBW <lwollrab@gmail.com> wrote: >This is probably simple but I can't get it to work. I need to have >the number i...

how can I use arguments to sort and use data from selected dates
I need to produce graphs that relate to data over a given month, is there anyway I can set up my spread sheet to recognise that the inputted date has changed month and hence to put the new data into another table? It's not clear what you are really asking. If you are entering data into a cell, then that's where it will stay. I can't see how it can then be part of a new table. Am I missing something? Matt -- Mallycat ------------------------------------------------------------------------ Mallycat's Profile: http://www.excelforum.com/member.php?action=getinfo&user...

AVGXCH32.DLL Error Message Upon Loading
I'm on a Dell XP computer and get the following message everytime I start Outlook 2002: The add-in "C:\WINDOWS\SYSTEM\AVGXCH32.DLL" could not be installed or loaded. The problem may be resolved by using Detect & Repair on the Help menu When I use Detect & Repair and my MS Office 2002 CD.... it does not fix the problem. Any suggestions on how to eliminate this annoyance? Thanks for anyone's help on this. Chris <anonymous@discussions.microsoft.com> wrote: > I'm on a Dell XP computer and get the following message > everytime I start Outlook 2...

Reposted: My calender, Notes, contacts all can't use
1) I hv not activated my copy yet, however, it says i can use 13 more times. The problem is, when I open, there are error messages complaining of losing ..DLL files. Below is the message. "Unable to display the folder. Microsoft Outlook could not access the specified folder location. The .DLL file for the information service could not be found. MAPI was unable to load the information service PSTPRX.DLL. Be sure the service is correctly installed and configured." Any body can suggest what is happening, and how to make it work. fyi, i m going to syn OL with my PocketPC which I just ...

Does Excel use temporary files when modify?
Hi, Some times occur you modify a worksheet, then when you save, Excel freezes (like some other cases for Excel to lock). You can just kill Excel and then continue working, but then you loose all your changes. Then my question is: Does Excel keep a temporal copy of your worksheet with your changes? Like Word does, you know it because of the file with "~" prefix. It's very dificult to say a user that he lost all the changes made. I'll appreciate any idea. Regards, Alex Excel does have a AutoSave addin. If it has been installed it will be listed under the Tools menu. ...

using 2003 to open a '97 db
I have users with 2003 and Im trying to give the ability to open or use '97 data base. Ive tried 2 things 1: just open db. this works but as soon as they try and do some form operation an error comes up 'operation not supported on replicable databases that have not been converted to the current version' 2. create a 2003 db with linked tables pointing at the '97 database. The result of this is that the linked tables have the first three fields missing and are replaced with fields named s_GUID, s_Lineage, ect Shouldnt this be easy? I know I saw some very good user instruct...

creating signatures using vc++
hi, i have to create add-in or something. My main objective is creating a COM Add-in for MS Outlook using vc++ When ever there is a mail going to be sent,my signature has to be added when the mail left for its destinaiton. how can i create that one using vc++ -- Regards, RamakoteswaraRao Koti So why cannot you use the default OL sig process? "Ram" <koti@nannacomputers.com> wrote in message news:uYppszlCGHA.736@TK2MSFTNGP10.phx.gbl... > hi, > > i have to create add-in or something. > My main objective is creating a COM Add-in for M...