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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:51:57+00:00 2026-05-10T21:51:57+00:00

All objects in my program inherit from a Container class. The Container class has

  • 0

All objects in my program inherit from a Container class. The Container class has a virtual BaseNode* getParent() const; method and a virtual void setParent(BaseNode *p); method.

I have a Set class (Set in a tennis match, not a data structure) which has the Match class as it’s parent (via setParent()) but since Set inherits from Container, The program creates a tree structure from the top down and the Set class is a child, it doesn’t need to have methods to track and maintain information about it’s parent beyond what Container provides.

The error C++: invalid conversion from ‘BaseNode*’ to ‘Match*’ shows up in the method below when I try to compile my program. (Player* getPlayer1() const; only exists in the Match class)

Player* Set::getPlayer1() const{     return getParent()->getPlayer1(); } 

This is my inheritance structure for Match. (Note that TreeNode is a template)

Match -> TreeNode<Set> -> BaseNode -> Container 

I don’t understand why I’m getting a conversation error. I have tried reading my textbook but it’s a rather poor reference. Google just provided too much irrelevant information.

Edit

Player* Set::getPlayer1() const{     return dynamic_cast<Match>(getParent())->getPlayer1(); } 

causes

error: cannot dynamic_cast ‘#‘obj_type_ref’ not supported by dump_expr#<expression error>((&((const Set*)this)->Set::<anonymous>))’ (of type ‘class BaseNode*’) to type ‘class Match’ (target is not pointer or reference) 

Edit 2

I just realized I need dynamic_cast<Match*> which works.

  • 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. 2026-05-10T21:51:58+00:00Added an answer on May 10, 2026 at 9:51 pm

    The problem is that getParent() returns a BaseNode*, which could be a pointer to any type of BaseNode – it might point to an unrelated class that also derives from BaseNode. If you’re 100% sure that the parent must be of type Match, you should cast the parent to a Match* first, and then you can call getPlayer() on that:

    Player* Set::getPlayer1() const{     return dynamic_cast<Match*>(getParent())->getPlayer1(); } 

    If the parent isn’t necessary a Match, then dynamic_cast might return NULL, so be sure to check for that.

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

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I downloaded a couple of .ico files from a freeware… May 11, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer You would need to modify your generated "Impl" class to… May 11, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer SlikSVN (download) looks like the most appropriate option given what… May 11, 2026 at 8:15 pm

Related Questions

I have a single NSDictionary object which contains a large number of custom objects.
I'm developing on the iPhone and I'm missing something about storing objects in an
I'm relatively new to NHibernate, but have been using it for the last few
I have a program that requires fast performance. Within one of its inner loops,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.