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 8733103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:34:40+00:00 2026-06-13T09:34:40+00:00

I have C++/CLI class that defines a property: public ref class AbstractOffer { public:

  • 0

I have C++/CLI class that defines a property:

public ref class AbstractOffer 
{
  public:
    AbstractOffer();

    property String^ Body;
};

In some function the AbstractOffer class is passed by const ref

foo(const AbstractOffer^ ao)
{
  ao->Body;
}

When I call the property the method compiler gives the following error :-

error C2662: ‘ivrworx::interop::AbstractOffer::Body::get’ : cannot
convert ‘this’ pointer from ‘const ivrworx::interop::AbstractOffer’
to ‘ivrworx::interop::AbstractOffer %’ 1> Conversion loses
qualifiers

It seems somehow connected to const. How can I call the Body property of the object if the object reference is passed by const?

  • 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-06-13T09:34:42+00:00Added an answer on June 13, 2026 at 9:34 am

    The only way I know to get round this is the cast away the const-ness. As long as you don’t modify the object, it should be fine. (If you do modify it, I’ve no idea what the outcome will be).
    i.e. change your function to be

    void foo(const AbstractOffer^ ao)
    {
      const_cast<AbstractOffer^>(ao)->Body;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++/CLI class: public ref class Foobar { public: // methods here
I have a C++/CLI class library project in VS2005 that i am having some
I have an Assembly(A) which defines a Managed class which has a public constructor
I have a function that is marked to be handled asynchronously by delayed_job: class
I have a C++/CLI DLL that uses some managed code (written in C#). I
I have declared C++/CLI class as below namespace testcominterface { [ComVisible(true)] [Guid(FFCA805F-8DAB-4AF8-A7B7-B488136E8177)] public interface
I have a cli application that doesn't like the usage of wildcards. In this
I have a C++/CLI project that wraps around an unmanaged C compression library, and
If I define a new ref class in C++/CLI, can I then use this
Want to verify that my understanding of how this works. Have a C++ Class

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.