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

  • Home
  • SEARCH
  • 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 8228109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:21:15+00:00 2026-06-07T16:21:15+00:00

I am getting this compile error: error: invalid conversion from ‘const MyClass*’ to ‘MyClass*’

  • 0

I am getting this compile error:

error: invalid conversion from 'const MyClass*' to 'MyClass*'

Here is the code:

std::tr1::shared_ptr<MyClass> myClassA;
const MyClass* myClassB;
myClassA = std::tr1::shared_ptr<MyClass>(myClassB); // error here

I think I understand the error, just don’t know how to fix. I need myClassB to be a const so how to convert/copy classB to a shared_ptr?

  • 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-07T16:21:16+00:00Added an answer on June 7, 2026 at 4:21 pm

    You’ll need a shared pointer to a const object:

    std::tr1::shared_ptr<const MyClass> myClassA;
                         ^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting following error error: invalid conversion from ‘const int*’ to ‘int*’ Following
I'm trying to compile the next code, but I'm getting this error on the
Can anyone explain why I'm getting this compile error? Duplicate 'Rad.Core.Aop.MethodArgumentValidation' attribute E:\Scripting\Rad.Core\Properties\AssemblyInfo.cs This
I am getting this error during compile time (g++ 4.4.6): main.cpp: In function ‘int
Im getting this linker error that won't let me compile. It only happens on
I am getting this weird RunTime error. The classes compile easy on eclipse but
Trying to compile a iPhone/iPad application with SDK3.2 and am getting this error: Undefined
I'm getting a nothing to repeat error when I try to compile this: search
why am i getting this LNK error when trying to compile this rsa library:
little help guys im still a newbie at c++ error: invalid conversion from 'VboVO*

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.