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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:02:09+00:00 2026-05-24T11:02:09+00:00

I need to identify what properties(strings) are processed by a method. So, I have

  • 0

I need to identify what properties(strings) are processed by a method. So, I have designed my method as below.

void method1( std::vector<String> * myVector )
{
   myVector = new std::vector<String>();  
   //do something;
   myVector->push_things;
}

So, I would call method1 from topMethod() like this.

topMethod()
{
   std::vector<String> * aVector = 0;
   method1( aVector );
   //process aVector to identify its contents;
}

Now, the vector myVector in method1() is getting populated fine. But its contents are unable at the caller method i.e., topMethod(). I’m not sure how they are getting freed. I feel that I’m allocating using new, so they should ideally be present at the caller location after the call..

Please provide your thoughts on what is going wrong.

  • 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-24T11:02:10+00:00Added an answer on May 24, 2026 at 11:02 am

    You should pass the pointer to vector by reference.
    You are allocating to a copy of the pointer to vector you passed not the pointer you passed.

    void method1( std::vector<int>* & myVector )
    

    This should fix it.

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

Sidebar

Related Questions

I have a list of keywords (strings) in which I need to identify any
I have a C code base and need to programmatically identify all of the
I need to identify a hour in a string in a Regex. The rules
I need to identify users according to an URI subset. It has the following
We need to identify and then process switch/case statements in code based on some
I need to identify the P(rocess) ID of an executing batch file from a
i need to identify who raise an exception to handle better str error, is
I need to identify all html elements on a page in a browser agnostic
I need to write php code to identify common e-mail errors, like inbox full
What are the type of indexes in oracle? How to identify the index need

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.