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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:48:49+00:00 2026-06-01T20:48:49+00:00

I know this is already a pointer, but I want to understand what this

  • 0

I know this is already a pointer, but I want to understand what this is exactly. Is it an address or is it a * type pointer?

If I were to store this into a variable how would I have to define that variable?

Lets take this as an example

class Adult
{
private:
 Child child;

public:
 Adult(){
  child = new Child(this);
  //to have something to hold onto and get back to the upper level of the hierarchy.
 }
};


class Child
{
private:
 Adult* my_adult;

public:
 Child();
 Child(Adult &hand){
  my_adult = hand;
 }
}

Okay, so where I run into the trouble is with the line of code that goes my_adult = hand;
It outputs this when I try to build the project, I will be horribly shocked if there are more behind this one.

sys/chin.cpp:19:14: error: cannot convert ‘Adult’ to ‘Adult*’ in assignment

So how does this work when being dealt with as a data type opposed to accessing members?

  • 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-01T20:48:50+00:00Added an answer on June 1, 2026 at 8:48 pm

    my_adult is a pointer, hand is not, pure and simple.

    You either need:

    class Child
    {
    private:
     Adult my_adult; //no pointer
    
    public:
     Child();
     Child(Adult &hand){
      my_adult = hand;
     }
    };
    

    or

    class Child
    {
    private:
     Adult* my_adult;
    
    public:
     Child();
     Child(Adult* hand){ //pointer parameter
      my_adult = hand;
     }
    };
    

    Your first example is also illegal:

    child = new Child(this);
    

    shouldn’t compile, since child is an object, not a pointer.

    child = Child(this);
    

    would be the correct version.

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

Sidebar

Related Questions

I know this question was already posted in StackOverflow but I either didnt understand
I know this question might have already been discussed a thousands of times but
I think I already know the answer to this but thought I would ask
I know that this has already been asked here but the answer (using a
I know this kind of questions have been asked already many times before. The
I think i already know the answer to this, but i cannot find anything
I feel like this is something I should already know, but I'm just not
Pardon me if this has already been asked (I know very little about Data
I know there are a few questions on stack already regarding this, and I
This seems like it should be something I already know. We need to run

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.