Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1013667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:08:19+00:00 2026-05-16T10:08:19+00:00

I am working in migration project from VC6 to VC9. In VC9 (Visual Studio

  • 0

I am working in migration project from VC6 to VC9. In VC9 (Visual Studio 2008), I got compilation error while passing const member to a method which is accepting reference. It is getting compiled without error in VC6.

Sample Program:

class A
{
};

typedef CList<A, A&> CAlist;

class B
{
    CAlist m_Alist;

public:
    const B& operator=( const B& Src);
};

const B& B::operator=( const B& Src)
{
    POSITION pos = Src.m_Alist.GetHeadPosition();

    while( pos != NULL)
    {
        **m_Alist.AddTail( Src.m_Alist.GetNext(pos) );**
    }

    return *this;
}

Error:
Whiling compiling above program, I got error as

error C2664: ‘POSITION CList::AddTail(ARG_TYPE)’ : cannot convert parameter 1 from ‘const A’ to ‘A &’

Please help me to resolve this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:08:20+00:00Added an answer on May 16, 2026 at 10:08 am

    That is because the GetNext() method returns a temoprary object of class A and the function AddTail takes the parameter A&. Since a temporary object can not be bound to a non-const reference you get the error. The simplest way to solve it is to break it into two statements. For example:

        while( pos != NULL)
        {
            A a =  Src.m_Alist.GetNext(pos);
            m_Alist.AddTail(a);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

recently, while working on a db2 -> oracle migration project, we came across this
I'm currently working on a migration project, to migrate data from the old db
I am currently working on a project which requires migration of content from different
I'm working on migration of data from a legacy system into our new app(running
I'm working on a blog migration from a custom built blog to Wordpress. One
I am working on some migration project, involves moving around quite a few stuff
I am currently working on an Umbraco 4 to 5 migration project . I
I am working on a jsf migration project. In the process of migration to
Using Visual Studio 2010 SP1, SQL server 2008: Motherboard recently failed and I migrated
I am working on a project that deals with migration of Oracle db to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.