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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:57:02+00:00 2026-06-07T14:57:02+00:00

What happens to the memory location when I initialize a variable in c++ more

  • 0

What happens to the memory location when I initialize a variable in c++ more than once? For example:

LPWSTR sampleString = new whcar_t[10];
//some operations here
sampleString = new wchar_t[2];
//some operations here
sampleString = new wchar_t[25];
//some operations here

If I delete the memory by using delete [] sampleString; will all the associated memory locations be cleared?

  • 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-07T14:57:04+00:00Added an answer on June 7, 2026 at 2:57 pm

    No, only the last one. All the rest will be lost forever. This is what is called “a memory leak”.

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

Sidebar

Related Questions

The function may move the memory block to a new location, in which case
I am always confused about static variables, and the way memory allocation happens for
What exactly happens, in terms of memory, when i declare something like: char arr[4];
When you new an object in C# a few things must happen: memory for
What happens in the following example? struct B { }; struct D1 : B
What happens in memory when we pass a value type - which has been
In C, declaring a char pointer like this char* p=Hello; allocates some memory for
Context.xml <jdbc:initialize-database data-source=dataSource ignore-failures=ALL> <jdbc:script location=classpath:scrubd.sql/> </jdbc:initialize-database> <bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource> <property name=driverClassName value=org.hsqldb.jdbc.JDBCDriver/> <property
Can we access any physical memory via some kernel code.? Because, i wrote a
I'm writing a program (a theorem prover as it happens) whose memory requirement is

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.