Click here to Skip to main content
15,888,070 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am converting a project from Visual Studio 6 to Visual Studio 2010, and in VS 2010. The following line:

C++
m_string.AddTail((CList *)&t.m_string);


gives the compile error:

error C2664: 'POSITION CList<type,arg_type>::AddTail(ARG_TYPE)' : cannot convert parameter 1 from '<clist><type,arg_type> *' to 'ATL::CStringT<BaseType,StringTraits> '
          with
          [
              TYPE=CString,
              ARG_TYPE=CString &
          ]
          and
          [
              TYPE=CTickLabel::=::CString,
              ARG_TYPE=CTickLabel::=::CString
          ]
          and
          [
              BaseType=char,
              StringTraits=StrTraitMFC<char>
          ]


Any help is greatly appreciated!!!!

Scott

///////////////////////UPDATE///////////////////////////////////

The definition of m_string is:

C++
CList <cstring,> m_string;


't' is a parameter passed into the routine as: 'const CTickLabel& t'

with:

C++
class CTickLabel : public CObject
{
    DECLARE_SERIAL(CTickLabel)
public:
    CList <cstring,> m_string;
    int m_angle;            // angle of ticklabel


Please e-mail if any questions about the structure of the problem.

Thank you.

Scott
Posted
Updated 28-Apr-12 14:15pm
v5
Comments
Chris Meech 27-Apr-12 14:05pm    
It would be clearer knowing what is the type of m_string? Is it really a string type or a list type? Also what is the type of 't'?
Jochen Arndt 28-Apr-12 2:53am    
Please use the Improve question link to update your question.
Albert Holguin 28-Apr-12 20:06pm    
That's an odd problem... seems like the compiler is choosing the incorrect version of CList::AddTail() based on the prototype.

1 solution

As Albert said it looks like the compiler's choosing the wrong overload for the function. However I can't see why you need the cast in the call if you're appending an object of exactly the same type. You should be able to write:

m_string.AddTail( &t.m_string );

So go back to VC6, take the cast out and see what it says when you try and compile it. That might give you (and us) a better idea of what's going on.

Another question, what's cstring?

Incidentally having public data members is a really crap idea. It's really hard to keep your class's invariants intact if you let any old Tom, Dick or Harry fiddle with their bits. AND m_string is a really bad name as well - it's a sodding list!

Another thing I've just noticed... you're not explicitly telling the compiler what ARG_TYPE is. Perhaps specifying that (i.e. CList<cstring,cstring & >) might help.
Cheers,

Ash
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900