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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:12:21+00:00 2026-06-15T23:12:21+00:00

Given the following sample code: #include <iostream> #include <memory> using namespace std; struct A

  • 0

Given the following sample code:

#include <iostream>
#include <memory>
using namespace std;

struct A {
public:
    A(int aa) : a(aa) {}
    int a;
    virtual ~A() {}
};
struct B : A {
public:
    B(int aa, int bb) : A(aa), b(bb) {}
    int b;
};

void f(shared_ptr<A> a){
    shared_ptr<B> b = dynamic_pointer_cast<B>(a);
    if (b) {
        cout << b->b << endl;
    } else {
        cout << a->a << endl;
    }
}

int main() {
    auto a = make_shared<A>(3);
    auto b = make_shared<B>(7, 4);
    f(a);
    f(b);
    return 0;
}

Eclipse indicates that there is an error on the line

f(b);

saying Invalid arguments ' Candidates are: void f(std::shared_ptr<A>) '
because a shared_ptr<B> has been passed. This compiles and runs, and has output:

3
4

as expected.

The indexer and compiler have -std=c++11 specified.
The compiler also has the symbol __GXX_EXPERIMENTAL_CXX0X__ defined.

Is there any way to get rid of this error and its red squiggles in Eclipse (preferably without modifying the source)?

  • 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-15T23:12:22+00:00Added an answer on June 15, 2026 at 11:12 pm

    This has been fixed in later versions of CDT (I just tried it).

    You can use a nightly build of CDT using this repository:
    Go to Help, and enter the url http://download.eclipse.org/tools/cdt/builds/kepler/nightly

    If you don’t feel like using a nighty build, you should at least make sure you have the latest released version (at this writing it is 8.1.1), using http://download.eclipse.org/tools/cdt/releases/juno/

    My full setup of eclipse with C++11 is found here:
    http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following sample code: #include <iostream> using namespace std; class base { public:
Conside the following sample code below: #include <iostream> using namespace std; class base {
i have following code #include <iostream> #include <cstdlib> using namespace std; int main() {
Given this code sample: complex.h : #ifndef COMPLEX_H #define COMPLEX_H #include <iostream> class Complex
I have this code in C++ which is giving weird output: #include<iostream> using namespace
Given the following code: // range heap example #include <iostream> #include <algorithm> #include <vector>
Given the following code sample: uint8_t i, in, ni; i = in = 2;
The following code was been given from our school as a sample for circular
Hello , im using the following code to Retrieve the DOM from URL all
Given the following code snippet from Anthony Williams . A very basic tuple example

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.