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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:44:03+00:00 2026-05-26T22:44:03+00:00

This question might be silly, but I want to know, if a copy constructor

  • 0

This question might be silly, but I want to know, if a copy constructor is invoked when a pointer to an object is returned by a function?
Also,consider following:

A* a1 = new A(); 
A* a = a1.GetPointer();

A* GetPoineter()
{

.....
return new A();
}

so does

A* a = a1.GetPointer(); 

call copy constructor?

also if I delete a, will it delete the address pointed by a1 also?

  • 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-05-26T22:44:04+00:00Added an answer on May 26, 2026 at 10:44 pm

    No, it does not call the copy constructor since you are returning the address of the object, not the object itself.

    delete a; will only delete the object allocated in the GetPoineter function. a1 is untouched since it points to a completely different object.

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

Sidebar

Related Questions

This might be a silly a question. But I am just curious to know
This might be a silly question, but I want to ask if there is
This might be kind of a silly question, but in C++, when I want
This might be a bit of a silly question but; If I have two
I know this question might sound a little cheesy but this is the first
This might be a silly question but I am still learning. I have read
This might be a silly question but it struck me, and here i ask.
This might seem to be a silly question at first, but please read on.
This question might seem really silly to most of the enlightened folks here. But
This might be a silly question but I couldn't find a good answer in

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.