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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:34:06+00:00 2026-06-14T15:34:06+00:00

I have class A , then I made a vector of class A ;

  • 0

I have class A, then I made a vector of class A;
std::vector<A> b, and i initialize it correctly.

I have one member function of another class, which has a member pointer which point to a
vector of A;

In this class, I also have a member function, and inside this member function.
I fist build a reference to the vector of class A, and initialize it use the deference of the pointer, The reason is the member reference can only assign value once, so I use pointer, but inside the member function, the syntax of reference is more clean.

the question is, in the member function, if i delete the reference to that vector, does it only delete the reference or delete the whole container the pointer point to. The container contain object not pointer.

Thanks

  • 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-14T15:34:07+00:00Added an answer on June 14, 2026 at 3:34 pm

    When the reference goes out of scope it’s not going to destroy the original object.

    I assume this is the situation:

    class A {};
    
    class B
    {
         std::vector<A>* pA;
    
    public:
         B( std::vector<A>* p ): pA(p) {}
    
         void foo()
         {
              std::vector<A>& arr = *pA;
              //do stuff with arr
              // Arr and pA are still valid after the end of this function
         }
    };
    
    int main()
    {
        std::vector<A> Arr;
        Arr.push_back( A() );
    
        B b( &Arr );
        b.foo();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a class Customer which has a property FirstName . Then I
I have a base class Foo that has an Update() function, which I want
I have a class TxRx with a property called Common. Common then has a
I have a class which made of a ints and strings, but I also
i'm lost in this , i have a class that has three vector objects
I have two clusters as a class which has Cluster : class DocumentList :
Ok, so here is what I have: an abstract Object class which I made
Assume, we have: class B class A extends B trait T Then it holds:
I have a class that gets a movieClip and then using addChild adds it
I have noticed that it is possible to define a custom class and then

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.